public bool ResetPassword(ResetPasswordParameters parameters) { if (parameters == null) { throw new ClientException("It is not allowed to call this authentication service method with no parameters provided."); } _logger.Trace("ResetPassword"); parameters.Validate(); CheckPasswordStrength(parameters.NewPassword); int userId = WebSecurity.GetUserIdFromPasswordResetToken(parameters.PasswordResetToken); SimpleMembershipProvider provider = (SimpleMembershipProvider)Membership.Provider; string userName = provider.GetUserNameFromId(userId); _logger.Trace(() => "ResetPassword " + userName); bool successfulReset = SafeExecute( () => WebSecurity.ResetPassword(parameters.PasswordResetToken, parameters.NewPassword), "ResetPassword", userName); if (successfulReset && !string.IsNullOrEmpty(userName)) { SafeExecute( // Login does not need to be successful for this function to return true. () => { Login(new LoginParameters { UserName = userName, Password = parameters.NewPassword, PersistCookie = false }); }, "Login after ResetPassword", userName); } return(successfulReset); }
public bool ResetPassword(ResetPasswordParameters parameters) { if (parameters == null) throw new ClientException("It is not allowed to call this authentication service method with no parameters provided."); _logger.Trace("ResetPassword"); parameters.Validate(); CheckPasswordStrength(parameters.NewPassword); int userId = WebSecurity.GetUserIdFromPasswordResetToken(parameters.PasswordResetToken); SimpleMembershipProvider provider = (SimpleMembershipProvider)Membership.Provider; string userName = provider.GetUserNameFromId(userId); _logger.Trace(() => "ResetPassword " + userName); bool successfulReset = SafeExecute( () => WebSecurity.ResetPassword(parameters.PasswordResetToken, parameters.NewPassword), "ResetPassword", userName); if (successfulReset && !string.IsNullOrEmpty(userName)) SafeExecute( // Login does not need to be successful for this function to return true. () => { Login(new LoginParameters { UserName = userName, Password = parameters.NewPassword, PersistCookie = false }); }, "Login after ResetPassword", userName); return successfulReset; }
public async Task <bool> ResetPassword([FromBody] ResetPasswordParameters parameters) { ValidateForEmptyParameters(parameters); return(await _authenticationService.ResetPasswordAsync(parameters.UserName, parameters.NewPassword, parameters.PasswordResetToken)); }