public IActionResult OnPost(string provider, string returnUrl = null) { // Request a redirect to the external login provider. var redirectUrl = Url.Page("./ExternalLogin", pageHandler: "Callback", values: new { returnUrl }); var properties = _signInService.ConfigureExternalAuthenticationProperties(provider, redirectUrl); return(new ChallengeResult(provider, properties)); }
public IActionResult ExternalLogin(string provider, string returnUrl = null) { // Request a redirect to the external login provider. var redirectUrl = Url.Action(nameof(ExternalLoginCallback), "Account", new { returnUrl }); var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl); var systemProperties = new Microsoft.AspNetCore.Authentication.AuthenticationProperties { IsPersistent = properties.IsPersistent, RedirectUri = properties.RedirectUri, AllowRefresh = properties.AllowRefresh, ExpiresUtc = properties.ExpiresUtc, IssuedUtc = properties.IssuedUtc }; return(Challenge(systemProperties, provider)); }
public async Task <IActionResult> LinkLogin(string provider) { // Clear the existing external cookie to ensure a clean login process await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); // Request a redirect to the external login provider to link a login for the current user var redirectUrl = Url.Action(nameof(LinkLoginCallback)); var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, _userManager.GetUserId(User)); var systemProperties = new Microsoft.AspNetCore.Authentication.AuthenticationProperties { IsPersistent = properties.IsPersistent, RedirectUri = properties.RedirectUri, AllowRefresh = properties.AllowRefresh, ExpiresUtc = properties.ExpiresUtc, IssuedUtc = properties.IssuedUtc }; return(new ChallengeResult(provider, systemProperties)); }