Example #1
0
        public async Task <IActionResult> ForgotPassword([FromBody] ForgotPasswordRequest request)
        {
            var shopUser = await _userManager.FindByEmailAsync(request.Email);

            if (shopUser != null)
            {
                var resetPasswordToken = EncodeHelper.Base64Encode(await _userManager.GeneratePasswordResetTokenAsync(shopUser));
                var resetLink          = UrlExtensions.ResetPasswordLink(shopUser.Id, resetPasswordToken,
                                                                         _configuration["RedirectDomain"]);
                await _emailSender.SendResetPasswordEmailAsync(request.Email, resetLink);

                return(StatusCode((int)HttpStatusCode.OK, "Password recovery confirmation link was sent to your e-mail."));
            }

            return(StatusCode((int)HttpStatusCode.NotFound,
                              new ErrorResponse(ErrorReasons.NotFound, "User was not found.")));
        }