コード例 #1
0
 public async Task <IActionResult> ForgotPasswordAsync([FromBody] UserForgotPasswordRq model)
 {
     try
     {
         return(Ok(await _authService.ForgotPasswordAsync(model)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #2
0
ファイル: AuthService.cs プロジェクト: honam867/Agrifood
        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);
        }