Created
January 9, 2024 20:46
-
-
Save TylerCode/dd988e1ed63b880e7456b51ccea60ec2 to your computer and use it in GitHub Desktop.
Login page for Auth0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Authentication; | |
using Auth0.AspNetCore.Authentication; | |
using Microsoft.AspNetCore.Mvc.RazorPages; | |
namespace MyApplication.Pages | |
{ | |
public class LoginModel : PageModel | |
{ | |
public async Task OnGet(string redirectUri, string? invitation = null, string? organization = null) | |
{ | |
var authenticationPropertiesBuilder = new LoginAuthenticationPropertiesBuilder() | |
.WithRedirectUri(redirectUri ?? "/home"); | |
if (invitation != null) | |
{ | |
authenticationPropertiesBuilder.WithInvitation(invitation); | |
} | |
if (organization != null) | |
{ | |
authenticationPropertiesBuilder.WithOrganization(organization); | |
} | |
var authenticationProperties = authenticationPropertiesBuilder.Build(); | |
await HttpContext.ChallengeAsync(Auth0Constants.AuthenticationScheme, authenticationProperties); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment