public ActionResult RemoveAccountList() { var linkedAccounts = userManager.GetLogins(User.Identity.GetUserId()); ViewBag.ShowRemoveButton = ControllerUtils.HasPassword(userManager, User) || linkedAccounts.Count > 1; return(PartialView("_RemoveAccountPartial", linkedAccounts)); }
public ActionResult Index() { if (User.Identity.GetUserId() == null || ControllerUtils.HasPassword(userManager, User)) { return(View()); } return(RedirectToAction("Manage", "Account")); }
public async Task <ActionResult> Manage(ManageUserViewModel model) { var hasPassword = ControllerUtils.HasPassword(userManager, User); ViewBag.HasLocalPassword = hasPassword; ViewBag.ReturnUrl = Url.Action("Manage"); if (hasPassword) { if (ModelState.IsValid) { var result = await userManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); if (result.Succeeded) { return(RedirectToAction("Manage", new { Message = ManageMessageId.PasswordChanged })); } this.AddErrors(result); } else { ModelState.AddModelError("", "Есть ошибки, давай поправим"); } } else { // User does not have a password so remove any validation errors caused by a missing OldPassword field var state = ModelState["OldPassword"]; state?.Errors.Clear(); if (ModelState.IsValid) { var result = await userManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword); if (result.Succeeded) { return(RedirectToAction("Manage", new { Message = ManageMessageId.PasswordSet })); } this.AddErrors(result); } else { ModelState.AddModelError("", "Есть ошибки, давай поправим"); } } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> Manage(ManageMessageId?message, string provider = "", string otherUserId = "") { ViewBag.StatusMessage = message?.GetAttribute <DisplayAttribute>().GetName(); if (message == ManageMessageId.AlreadyLinkedToOtherUser) { var otherUser = await userManager.FindByIdAsync(otherUserId); ViewBag.StatusMessage += $" {provider ?? ""}. Аккаунт уже привязан к пользователю {otherUser?.UserName ?? ""}."; } ViewBag.IsStatusError = message?.GetAttribute <IsErrorAttribute>()?.IsError ?? IsErrorAttribute.DefaultValue; ViewBag.HasLocalPassword = ControllerUtils.HasPassword(userManager, User); ViewBag.ReturnUrl = Url.Action("Manage"); return(View()); }
public PartialViewResult ChangeDetailsPartial() { var user = userManager.FindByName(User.Identity.Name); var hasPassword = ControllerUtils.HasPassword(userManager, User); return(PartialView(new UserViewModel { Name = user.UserName, UserId = user.Id, HasPassword = hasPassword, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email })); }
// // GET: /Account/Manage public ActionResult Manage(ManageMessageId?message) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Пароль был изменен." : message == ManageMessageId.SetPasswordSuccess ? "Пароль установлен." : message == ManageMessageId.RemoveLoginSuccess ? "Внешний логин удален." : message == ManageMessageId.Error ? "Ошибка." : ""; ViewBag.HasLocalPassword = ControllerUtils.HasPassword(userManager, User); ViewBag.ReturnUrl = Url.Action("Manage"); return(View()); }