Ejemplo n.º 1
0
        public async Task OnGetAsync(string returnUrl = null)
        {
            if (!string.IsNullOrEmpty(ErrorMessage))
            {
                ModelState.AddModelError(string.Empty, ErrorMessage);
            }

            returnUrl ??= Url.Content("~/");

            // Clear the existing external cookie to ensure a clean login process
            await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);

            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();

            ReturnUrl = returnUrl;
        }
        public async Task <ExternalLoginsViewModel> GetExternalLogins(ClaimsPrincipal identityUser)
        {
            var user = await GetApplicationUser(identityUser);

            var vm = new ExternalLoginsViewModel {
                CurrentLogins = await _userManager.GetLoginsAsync(user)
            };

            vm.OtherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync())
                             .Where(auth => vm.CurrentLogins.All(ul => auth.Name != ul.LoginProvider))
                             .ToList();

            vm.ShowRemoveButton = await _userManager.HasPasswordAsync(user) || vm.CurrentLogins.Count > 1;

            return(vm);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnGetAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            CurrentLogins = await _userManager.GetLoginsAsync(user);

            OtherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync())
                          .Where(auth => CurrentLogins.All(ul => auth.Name != ul.LoginProvider))
                          .ToList();
            ShowRemoveButton = user.PasswordHash != null || CurrentLogins.Count > 1;
            return(Page());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> ExternalLogins()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }

            var model = new ExternalLoginsViewModel {
                CurrentLogins = await _userManager.GetLoginsAsync(user)
            };

            model.OtherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync())
                                .Where(auth => model.CurrentLogins.All(ul => auth.Name != ul.LoginProvider))
                                .ToList();
            model.ShowRemoveButton = await _userManager.HasPasswordAsync(user) || model.CurrentLogins.Count > 1;

            model.StatusMessage = StatusMessage;

            return(View(model));
        }
Ejemplo n.º 5
0
 public async Task OnGetAsync(string returnUrl = null)
 {
     ReturnUrl      = returnUrl;
     ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
 }