// // GET: /Manage/Index public virtual async Task <ActionResult> Index(ManageMessageId?message) { ViewBag.StatusMessage = message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." : message == ManageMessageId.Error ? "An error has occurred." : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." : ""; var userId = User.Identity.GetUserId(); var model = new IndexViewModel { HasPassword = HasPassword(), PhoneNumber = await CustomUser.GetPhoneNumberAsync(userId), TwoFactor = await CustomUser.GetTwoFactorEnabledAsync(userId), Logins = await CustomUser.GetLoginsAsync(userId), BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId) }; return(View(model)); }
// // GET: /Manage/ManageLogins public virtual async Task <ActionResult> ManageLogins(ManageMessageId?message) { ViewBag.StatusMessage = message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed." : message == ManageMessageId.Error ? "An error has occurred." : ""; var user = await CustomUser.FindByIdAsync(User.Identity.GetUserId()); if (user == null) { return(View("Error")); } var userLogins = await CustomUser.GetLoginsAsync(User.Identity.GetUserId()); var otherLogins = AuthenticationManager.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => auth.AuthenticationType != ul.LoginProvider)).ToList(); ViewBag.ShowRemoveButton = user.Password != null || userLogins.Count > 1; return(View(new ManageLoginsViewModel { CurrentLogins = userLogins, OtherLogins = otherLogins })); }