I have the following code in my action:
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://mynamespace.com';
console.log('email: ' + event.user.email);
api.idToken.setCustomClaim(`${namespace}/email`, event.user.email);
};
I have applied the flow and everything looks deployed.
The only thing I don’t understand is I am never calling the authorize endpoint from my Blazor Server app unless it is handled under the covers. In my index.razor page, I have the following code:
@code {
private string Username = "Anonymous User";
private string UserId = "";
private string Email = "";
protected override async Task OnInitializedAsync()
{
var state = await AuthState.GetAuthenticationStateAsync();
Username = state.User.Identity.Name ?? string.Empty;
UserId = state.User.Claims
.Where(c => c.Type.Equals(@"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))
.Select(c => c.Value)
.FirstOrDefault() ?? string.Empty;
// Remove Auth0 prefix
UserId = UserId.Split('|')[1];
Email = state.User.Claims
.Where(c => c.Type.Equals(@"https://mynamespace.com/email"))
.Select(c => c.Value)
.FirstOrDefault() ?? string.Empty;
await base.OnInitializedAsync();
}
}
What I don’t understand is how it knows to execute the Login flow for the application because right now, the email claim is not getting to the application. What am I missing?