Пример #1
0
 public ActionResult ForgotPasswordConfirmation(ForgotPasswordViewModel model)
 {
     return View(model);
 }
Пример #2
0
        public async Task<ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);
                //if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                //{
                //    model.Exist = false;
                //    // Don't reveal that the user does not exist or is not confirmed
                //    return View("ForgotPasswordConfirmation", model);
                //}
                if (user == null)
                {
                    model.Exist = false;
                    // Don't reveal that the user does not exist or is not confirmed
                    return View("ForgotPasswordConfirmation", model);
                }
                var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking here: <a href=\"" + callbackUrl + "\">link</a>");
                ViewBag.Link = callbackUrl;
                model.Exist = true;
                return View("ForgotPasswordConfirmation", model);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }