Exemple #1
0
 public async Task<ActionResult> ChangePassword(
     ChangePasswordViewModel model)
 {
     if (!this.ModelState.IsValid)
     {
         return this.View(model);
     }
     var result =
         await
         this.UserManager.ChangePasswordAsync(
             this.User.Identity.GetUserId(),
             model.OldPassword,
             model.NewPassword);
     if (result.Succeeded)
     {
         var user =
             await
             this.UserManager.FindByIdAsync(
                 this.User.Identity.GetUserId());
         if (user != null)
         {
             await this.SignInManager.SignInAsync(user, false, false);
         }
         return this.RedirectToAction(
             "Index",
             new { Message = ManageMessageId.ChangePasswordSuccess });
     }
     this.AddErrors(result);
     return this.View(model);
 }
 public async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess });
     }
     AddErrors(result);
     return View(model);
 }