Example #1
0
        public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
                return View(model);

            AuthUser user = await UserManager.FindByNameAsync(model.Email);
            if (user == null)
                // Don't reveal that the user does not exist
                return RedirectToAction("ResetPasswordConfirmation", "Home");

            IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);

            //await UserManager.GeneratePasswordResetTokenAsync
            if (result.Succeeded)
                return RedirectToAction("ResetPasswordConfirmation", "Home");

            ModelState.AddModelError("", "Failed to reset the account.");
            return View();
        }
Example #2
0
        public async Task<ActionResult> ResetPassword(string userId, string code)
        {
            if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(userId))
                return View("Error");

            AuthUser user = await UserManager.FindByIdAsync(userId);
            if (user == null)
                return View("Error");

            ViewBag.email = user.Email;

            ResetPasswordViewModel ResetPasswordViewModel = new ResetPasswordViewModel();
            ResetPasswordViewModel.Code = code;
            ResetPasswordViewModel.Email = user.Email;

            return View("ResetPassword", ResetPasswordViewModel);
        }