Example #1
0
        private void btnSubmitGroup2_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string newPswd      = ValidateUser.ValidatePassword(pbNewPswd.Password);
                string newPswdAgain = pbNewPswdAgain.Password;

                if (newPswd == newPswdAgain)
                {
                    Authentification.ChangePassword(_userId, newPswd);
                    pbNewPswd.Password      = string.Empty;
                    pbNewPswdAgain.Password = string.Empty;
                    DialogHelper.ShowInfo("Heslo bylo úspěšně změněno.");
                    InitializeInterface();
                }
                else
                {
                    pbNewPswdAgain.Password = string.Empty;
                    throw new PasswordsDoNotMatchException();
                }
            }
            catch (InvalidAuthPasswordException ex)
            {
                pbNewPswd.Password = string.Empty; pbNewPswd.Focus();
                DialogHelper.ShowWarning(ex.Message);
            }
            catch (PasswordsDoNotMatchException ex)
            {
                DialogHelper.ShowWarning(ex.Message);
            }
            catch
            {
                DialogHelper.ShowError("Heslo nemohlo být změněno.");
            }
        }
Example #2
0
        private void pswdSubmit_Click(object sender, RoutedEventArgs e)
        {
            // Zkontrolovat původní heslo
            bool isUserAuthentificated = false;

            try
            {
                string enteredPswd = ValidateUser.ValidatePassword(pbFormerPswd.Password);
                if (Authentification.CheckUserPassword(enteredPswd))
                {
                    // Heslo ověřeno, pokračujeme dále --> kontrola nového hesla
                    isUserAuthentificated = true;
                }
                else
                {
                    DialogHelper.ShowWarning("Původní heslo nebylo zadáno správně.");
                    pbFormerPswd.Password = string.Empty;
                }
            }
            catch (UserNotLoggedInException ex)
            {
                DialogHelper.ShowError(ex.Message);
            }
            catch (InvalidAuthPasswordException ex)
            {
                DialogHelper.ShowWarning(ex.Message);
            }
            catch
            {
                DialogHelper.ShowError("Uživatel nemohl být ověřen.");
            }

            // Validace nového hesla
            if (isUserAuthentificated)
            {
                try
                {
                    string newPswd      = ValidateUser.ValidateNewPassword(pbNewPswd.Password);
                    string newPswdAgain = pbNewPswdAgain.Password;
                    if (newPswd == newPswdAgain)
                    {
                        Authentification.ChangePassword(Authentification.AuthUser.Id, newPswd);
                        DialogHelper.ShowInfo("Heslo bylo úspěšně změněno.");
                        InitializeInterface();
                    }
                    else
                    {
                        throw new PasswordsDoNotMatchException();
                    }
                }
                catch (InvalidNewPasswordException ex)
                {
                    DialogHelper.ShowWarning(ex.Message);
                }
                catch (PasswordsDoNotMatchException ex)
                {
                    DialogHelper.ShowWarning(ex.Message);
                }
                catch
                {
                    DialogHelper.ShowError("Heslo nemohlo být změněno.");
                }
            }
        }