public async Task <IActionResult> ForgotPasswordAsync([FromBody] UserForgotPasswordRq model) { try { return(Ok(await _authService.ForgotPasswordAsync(model))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <bool> ForgotPasswordAsync(UserForgotPasswordRq model) { var user = await _userManager.FindByEmailAsync(model.Email); if (user == null) { return(false); } string code = await _userManager.GeneratePasswordResetTokenAsync(user); //update user await _emailService.SendEmailForgotPasswordAsync(user.Email, user.UserName, code); return(true); }