public async Task <Response> ResetPasswordRequest(string email) { var user = await _repository.GetByEmail(email); if (user == null) { return(new BusinessConflictErrorResponse(new [] { new Error { Code = ErrorCodes.Business.UserDoesNotExists, Message = ErrorMessages.Business.UserDoesNotExists, Field = ErrorFields.User.Email } })); } var code = CodeHelper.GenerateCodeAsGuid(); await _changePasswordRepository.ActivateAllRequestsForUser(user.Id); await _changePasswordRepository.AddRequest(user.Id, code); return(await _emailNotificationsService.SendResetPasswordEmail(user.Email, code)); }
public async Task <Response> ResetPasswordRequest(string email) { var user = await _usersRepository.GetByEmail(email); if (user == null) { return(new Response()); } if (user.RoleId != RoleGuid.Admin) { return(new Response()); } var code = CodeHelper.GenerateCodeAsGuid(3); await _changePasswordRepository.ActivateAllRequestsForUser(user.Id); await _changePasswordRepository.AddRequest(user.Id, code); return(await _emailNotificationsService.SendResetAdminPasswordEmail(user.Email, code)); }