public IActionResult ForgotPassword([FromBody] UserForgotPasswordRequest request) { try { _userService.SendForgotPasswordEmail(request.Email); return(new ObjectResult(new { StatusCode = ResponseConstants.Success })); } catch (UserNotFoundException) { return(new ObjectResult(new { StatusCode = ResponseConstants.UserNotExist })); } catch (Exception) { return(new ObjectResult(new Result { StatusCode = ResponseConstants.Unknown })); } }
public async Task <ActionResult <UserForgotPasswordResponse> > ForgotPassword([FromBody] UserForgotPasswordRequest request) { _logger.LogInformation($"{nameof(ForgotPasswordController)}: Forgot Password request with email = {request.Email}"); var changePasswordResult = await _userSettingsService.GenerateAndChangePasswordToAsync(request.Email); if (changePasswordResult) { _logger.LogError($"{nameof(ForgotPasswordController)}: user with email = {request.Email}: password changed"); return(new UserForgotPasswordResponse { Email = request.Email, IsConfirmationMailSent = true, IsUserExists = true }); } _logger.LogInformation($"{nameof(ForgotPasswordController)}: user with email = {request.Email}: unsuccessful password changing"); return(new UserForgotPasswordResponse { Email = request.Email, Error = "Unsuccessful password changing", IsConfirmationMailSent = false, IsUserExists = false }); }