public async Task <IActionResult> OnGet() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } RequirePassword = await _userManager.HasPasswordAsync(user); return(Page()); }
public async Task <IActionResult> OnGetAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID 'user.Id'.")); } CurrentLogins = await _userManager.GetLoginsAsync(user); var possibleOtherLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()) .Where(auth => CurrentLogins.All(ul => auth.Name != ul.LoginProvider)) .ToList(); GoogleLogin = possibleOtherLogins.SingleOrDefault(x => x.Name == "Google"); MicrosoftLogin = possibleOtherLogins.SingleOrDefault(x => x.Name == "Microsoft"); TwitchLogin = possibleOtherLogins.SingleOrDefault(x => x.Name == "Twitch"); PatreonLogin = possibleOtherLogins.SingleOrDefault(x => x.Name == "Patreon"); DiscordLogin = possibleOtherLogins.SingleOrDefault(x => x.Name == "Discord"); ShowRemoveButton = user.PasswordHash != null || CurrentLogins.Count > 1; return(Page()); }