private ChangePassword ( string userName, string oldPassword, string newPassword ) : void | ||
userName | string | |
oldPassword | string | |
newPassword | string | |
리턴 | void |
public void ChangePassword_Click(object sender, EventArgs e) { using(LoginService service = new LoginService()) { try { if (!NewPassword.Text.Equals(ConfirmNewPassword.Text) || NewPassword.Text.Equals(string.Empty)) { ErrorMessage.Text = ErrorMessages.PasswordsDontMatch; ErrorMessagePanel.Visible = true; } else { service.ChangePassword(Username.Text, OriginalPassword.Value, NewPassword.Text); SessionManager.InitializeSession(Username.Text, NewPassword.Text, ImageServerConstants.DefaultApplicationName /*TODO: must change this */ ); } } catch (Exception ex) { ErrorMessage.Text = ex.Message; ErrorMessagePanel.Visible = true; SetInputFocus(NewPassword); // May want to elimiate this. Platform.Log(LogLevel.Error, ex, "Unexpected exception changing password: {0}.", ex.Message); } } }
public void ChangePassword_Click(object sender, EventArgs e) { using(LoginService service = new LoginService()) { try { SessionInfo session = service.Login(ChangePasswordUsername.Text, OriginalPassword.Text, ImageServerConstants.DefaultApplicationName); if (!NewPassword.Text.Equals(ConfirmNewPassword.Text) || NewPassword.Text.Equals(string.Empty)) { ErrorMessage.Text = ErrorMessages.PasswordsDoNotMatch; ErrorMessagePanel.Visible = true; } else { service.ChangePassword(ChangePasswordUsername.Text, OriginalPassword.Text,NewPassword.Text); session = service.Login(ChangePasswordUsername.Text, NewPassword.Text, ImageServerConstants.DefaultApplicationName); SessionManager.InitializeSession(session); if (LoginPasswordChange.Checked) { Response.Redirect( FormsAuthentication.GetRedirectUrl(ChangePasswordUsername.Text, false), false); } else { ModalDialog1.Hide(); } } } catch(ArgumentException ex) { Platform.Log(LogLevel.Error, ex, "Unable to change password for {0}: {1}", ChangePasswordUsername.Text, ex.Message); string error = String.Format(ErrorMessages.ChangePasswordError, ex.Message); ShowError(error); } catch (PasswordExpiredException ex) { Platform.Log(LogLevel.Error, ex, "Unable to change password for {0}: {1}", ChangePasswordUsername.Text, ex.Message); ShowError(ErrorMessages.PasswordExpired); } catch (UserAccessDeniedException ex) { Platform.Log(LogLevel.Error, ex, "Unable to change password for {0}: {1}", ChangePasswordUsername.Text, ex.Message); ShowError(ErrorMessages.UserAccessDenied); } catch (RequestValidationException ex) { // NOTE: The server is throwing FaultException<RequestValidationException> when username or password doesn't match the configured policy Platform.Log(LogLevel.Error, ex, "Unable to change password for {0}: {1}", ChangePasswordUsername.Text, ex.Message); string error = String.Format(ErrorMessages.PasswordPolicyNotMet); ShowError(error); } catch (CommunicationException ex) { Platform.Log(LogLevel.Error, ex, ErrorMessages.CannotContactEnterpriseServer); ShowError(ErrorMessages.CannotContactEnterpriseServer); } catch (Exception ex) { ShowError(ex.Message); // May want to elimiate this. Platform.Log(LogLevel.Error, ex, "Unexpected exception changing password: {0}.", ex.Message); } } }