public async Task ResetPassword(SystemUserResetPasswordModel model) { var systemUser = await GetItem(new Guid(model.Id)); if (systemUser == null) { throw new UserNotFoundException(); } if (string.Compare(_hashingService.DecryptString(systemUser.Password), model.ConfirmPassword, false) != 0) { throw new PasswordsDoNotMatchException(); } systemUser.Password = _hashingService.EncryptString(model.ResetPassword); systemUser = await _systemUsersManager.UpsertItemAsync(systemUser); }
public async Task <IActionResult> ResetPassword(SystemUserResetPasswordModel model) { try { await _systemUserService.ResetPassword(model); response = new ApiResponse(HttpStatusCode.OK, "System user password reset successfully.", null); return(Ok(new { response })); } catch (UserNotFoundException exception) { response = new ApiResponse(HttpStatusCode.NotFound, exception.Message, null); return(Ok(new { response })); } catch (PasswordsDoNotMatchException exception) { response = new ApiResponse(HttpStatusCode.Conflict, exception.Message, null); return(Ok(new { response })); } catch (Exception exception) { return(BadRequest("System user update failed. Error: " + exception.Message)); } }
public SystemUserResetPassword(SystemUserResetPasswordModel entity) { ResetPassword = entity.ResetPassword; ConfirmPassword = entity.ConfirmPassword; }