Пример #1
0
 public async Task<ActionResult> ResetPassword(ChangePasswordAndConfirmEmailVm model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = await UserManager.FindByIdAsync(model.userId);
     if (user == null)
     {
         // Don't reveal that the user does not exist
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     var result = await UserManager.ResetPasswordAsync(user.Id, model.code, model.newPassword);
     if (result.Succeeded)
     {
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     AddErrors(result);
     return View();
 }
Пример #2
0
        public async Task<ActionResult> ConfirmEmailAndChangePassword( ChangePasswordAndConfirmEmailVm Model )
        {
            if (ModelState.IsValid)
            {
                IdentityResult result;
                result = await UserManager.ConfirmEmailAsync(HttpUtility.UrlDecode(Model.userId), HttpUtility.UrlDecode(Model.code));
                if (!result.Succeeded)
                {
                    ModelState.AddModelError("", "Произошла ошибка при подтверждении Email. " + result.Errors.First());
                    return View(Model);
                }
                result = await UserManager.RemovePasswordAsync(Model.userId);
                if (! result.Succeeded)
                {
                    ModelState.AddModelError("", "Произошла ошибка при временного пароля. "+result.Errors.First());
                    return View(Model);
                } 
                result = await UserManager.AddPasswordAsync(Model.userId, Model.confirmNewPassword);
                if (!result.Succeeded)
                {
                    ModelState.AddModelError("", "Произошла ошибка при добавлении нового пароля. " + result.Errors.First());
                    return View(Model);
                }

                return RedirectToAction("Welcome");

            }
            return View(Model);
        }
Пример #3
0
 public ActionResult ResetPassword(string userId, string code)
 {
     ChangePasswordAndConfirmEmailVm model = new ChangePasswordAndConfirmEmailVm { userId = userId, code = code };
     return code == null ? View("Error") : View(model);
 }
Пример #4
0
 public ActionResult ConfirmEmailAndChangePassword(string userId, string code)
 {
     if (userId == null || code == null)
     {
         return View("Error");
     }
     ChangePasswordAndConfirmEmailVm model = new ChangePasswordAndConfirmEmailVm { userId = userId, code = code };
     return View("ConfirmEmailAndChangePassword",model);
 }