private void Save()
        {
            //TODO actual password checking with remote web server
            var storedPassword = "******";

            if (storedPassword != OriginalPassword.Unsecure())
            {
                Container.UI.ShowMessage(new MessageBoxViewModel
                {
                    Title   = "Error",
                    Message = "Invalid password"
                });
                return;
            }

            if (EditedPassword.Unsecure() != ConfirmPassword.Unsecure())
            {
                Container.UI.ShowMessage(new MessageBoxViewModel
                {
                    Title   = "Error",
                    Message = "Password mismatch"
                });
                return;
            }

            if (EditedPassword.Unsecure().Length == 0)
            {
                Container.UI.ShowMessage(new MessageBoxViewModel
                {
                    Title   = "Error",
                    Message = "You must enter a password"
                });

                return;
            }

            OriginalPassword = new SecureString();

            foreach (var c in EditedPassword.Unsecure().ToCharArray())
            {
                OriginalPassword.AppendChar(c);
            }

            IsEditing = false;
        }
Ejemplo n.º 2
0
            private IEnumerable <string> Validate()
            {
                if (!OriginalPassword.IsValidString())
                {
                    yield return("Please enter your original password");
                }

                if (!NewPassword.IsValidString())
                {
                    yield return("Please enter your new password");
                }

                if (NewPassword?.Length < 3)
                {
                    yield return("New password must be made up of at least 3 letters");
                }

                if (NewPassword != ConfirmPassword)
                {
                    yield return("Passwords do not match!");
                }
            }
Ejemplo n.º 3
0
 public override int GetHashCode()
 {
     return(OriginalPassword.GetHashCode());
 }