Skip to content

Instantly share code, notes, and snippets.

@TylerCode
Created January 9, 2024 20:46
Show Gist options
  • Save TylerCode/dd988e1ed63b880e7456b51ccea60ec2 to your computer and use it in GitHub Desktop.
Save TylerCode/dd988e1ed63b880e7456b51ccea60ec2 to your computer and use it in GitHub Desktop.
Login page for Auth0
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