Exemplo n.º 1
0
        //
        // GET: /Manage/LinkLoginCallback
        public async Task <ActionResult> LinkLoginCallback()
        {
            var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, IdentityUserId.ToString());

            if (loginInfo == null)
            {
                return(RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error }));
            }
            var result = await UserManager.AddLoginAsync(IdentityUserId, loginInfo.Login);

            return(result.Succeeded ? RedirectToAction("ManageLogins") : RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error }));
        }
Exemplo n.º 2
0
        //
        // GET: /Manage/Index
        public 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 model = new IndexViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(IdentityUserId),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(IdentityUserId),
                Logins            = await UserManager.GetLoginsAsync(IdentityUserId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(IdentityUserId.ToString())
            };

            return(View(model));
        }
Exemplo n.º 3
0
 public ActionResult LinkLogin(string provider)
 {
     // Request a redirect to the external login provider to link a login for the current user
     return(new AccountController.ChallengeResult(provider, Url.Action("LinkLoginCallback", "Manage"), IdentityUserId.ToString()));
 }