protected override void ExecuteResetPassword(object targetUserObject, ResetPasswordParameters resetPasswordParameters) { Guard.ArgumentNotNull(targetUserObject, "targetUserObject"); Guard.ArgumentNotNull(resetPasswordParameters, "resetPasswordParameters"); CustomResetPasswordEventArgs customResetPasswordEventArgs = new CustomResetPasswordEventArgs(targetUserObject, resetPasswordParameters); try { CustomResetPassword?.Invoke(this, customResetPasswordEventArgs); if (!customResetPasswordEventArgs.Handled) { this.TargetEmployee = (Employee)targetUserObject; KeyValuePair <HttpStatusCode, string> result = MultiTenantHelper.SetPassword(this.AuthenticatingEmployee, this.TargetEmployee, resetPasswordParameters.Password); if (result.Key == HttpStatusCode.OK) { this.TargetEmployee.SetPassword(resetPasswordParameters.Password); this.TargetEmployee.ChangePasswordOnFirstLogon = false; this.ObjectSpace.CommitChanges(); } if (SecuritySystem.CurrentUserId.Equals(ObjectSpace.GetKeyValue(targetUserObject))) { SecurityModule.TryUpdateLogonParameters(resetPasswordParameters.Password); } } } catch (Exception ex) { ToastMessageHelper.ShowErrorMessage(this.Application, ex, InformationPosition.Bottom); } }
protected override void ChangePassword(ChangePasswordParameters parameters) { Guard.ArgumentNotNull(parameters, "parameters"); try { CustomChangePasswordEventArgs customChangePasswordEventArgs = new CustomChangePasswordEventArgs(parameters); CustomChangePassword?.Invoke(this, customChangePasswordEventArgs); if (!customChangePasswordEventArgs.Handled) { if (!AuthenticatingEmployee.ComparePassword(parameters.OldPassword)) { throw new Exception(String.Format("{0} {1}", SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.OldPasswordIsWrong), SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.RetypeTheInformation))); } if (parameters.NewPassword != parameters.ConfirmPassword) { throw new Exception(String.Format("{0} {1}", SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.PasswordsAreDifferent), SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.RetypeTheInformation))); } if (AuthenticatingEmployee.ComparePassword(parameters.NewPassword)) { throw new Exception(String.Format("{0} {1}", SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.NewPasswordIsEqualToOldPassword), SecurityExceptionLocalizer.GetExceptionMessage(SecurityExceptionId.RetypeTheInformation))); } KeyValuePair <HttpStatusCode, string> result = MultiTenantHelper.SetPassword(AuthenticatingEmployee, AuthenticatingEmployee, parameters.NewPassword); if (result.Key == HttpStatusCode.OK) { AuthenticatingEmployee.SetPassword(parameters.NewPassword); AuthenticatingEmployee.ChangePasswordOnFirstLogon = false; this.ObjectSpace.SetModified(AuthenticatingEmployee); this.ObjectSpace.CommitChanges(); } SecurityModule.TryUpdateLogonParameters(parameters.NewPassword); if (!View.ObjectSpace.IsModified) { bool isCurrentUser = IsCurrentUser(View.ObjectSpace, View.CurrentObject); if (isCurrentUser) { View.ObjectSpace.ReloadObject(View.CurrentObject); } } } } catch (Exception ex) { ToastMessageHelper.ShowErrorMessage(this.Application, ex, InformationPosition.Bottom); } finally { parameters.ClearValues(); } }
protected void Application_Error(Object sender, EventArgs e) { if (ErrorHandling.GetApplicationError() != null) { ToastMessageHelper.ShowErrorMessage(WebApplication.Instance, ErrorHandling.GetApplicationError().Exception, InformationPosition.Bottom); } else if (Server.GetLastError() != null) { ToastMessageHelper.ShowErrorMessage(WebApplication.Instance, Server.GetLastError(), InformationPosition.Bottom); } ErrorHandling.ClearApplicationError(); Server.ClearError(); }
private void ExecuteErrorMessage(Controller Controller, Exception Exception, InformationPosition Position) { ToastMessageHelper.ShowErrorMessage(Controller.Application, Exception, Position); }