コード例 #1
0
        //TODO Fully implement modification of User credentials, perhaps via an Admin interface. If adding an Admin interface, add an auditing system to see modifications.

        #region Button-Click Methods

        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (Argon2.ValidatePassword(AppState.CurrentUser.Password, PswdCurrentPassword.Password))
            {
                if (PswdNewPassword.Password.Length >= 4 && PswdConfirmPassword.Password.Length >= 4)
                {
                    if (PswdNewPassword.Password == PswdConfirmPassword.Password)
                    {
                        if (PswdCurrentPassword.Password != PswdNewPassword.Password)
                        {
                            AppState.CurrentUser.Password = Argon2.HashPassword(PswdNewPassword.Password);
                            AppState.ModifyUser(AppState.CurrentUser);
                            AppState.DisplayNotification("Successfully changed password.", "Sulimn");
                            AppState.GoBack();
                        }
                        else
                        {
                            AppState.DisplayNotification("The new password can't be the same as the current password.", "Sulimn");
                        }
                    }
                    else
                    {
                        AppState.DisplayNotification("Please ensure the new passwords match.", "Sulimn");
                    }
                }
                else
                {
                    AppState.DisplayNotification("Your password must be at least 4 characters.", "Sulimn");
                }
            }
            else
            {
                AppState.DisplayNotification("Invalid current password.", "Sulimn");
            }
        }