Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @page "/authentication/login-callback"
- @using Microsoft.AspNetCore.Components.Authorization
- @using System.Text.Json
- @inject AuthenticationStateProvider AuthenticationStateProvider
- <p>@message</p>
- @code {
- private string message;
- protected override async Task OnInitializedAsync()
- {
- var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
- var user = authState.User;
- if (user.Identity.IsAuthenticated)
- {
- var claims = user.Claims;
- message = $"Name: {user.Identity.Name} \nClaims: {JsonSerializer.Serialize(claims)}";
- Console.WriteLine(message);
- }
- else
- {
- message = "User is not authenticated";
- }
- await base.OnInitializedAsync();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment