You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.6 KiB
44 lines
1.6 KiB
@page "/"
|
|
|
|
<PageTitle>Index</PageTitle>
|
|
|
|
@*<MudText Typo="Typo.h3" GutterBottom="true">Hello, world!</MudText>
|
|
<MudText Class="mb-8">Welcome to your new app, powered by MudBlazor!</MudText>
|
|
<MudAlert Severity="Severity.Normal">You can find documentation and examples on our website here: <MudLink Href="https://mudblazor.com" Typo="Typo.body2" Color="Color.Inherit"><b>www.mudblazor.com</b></MudLink></MudAlert>
|
|
*@
|
|
<AuthorizeView>
|
|
<Authorized>
|
|
<MudText Typo="Typo.h3" GutterBottom="true">Hello, world!</MudText>
|
|
<b>Hello, @context.User.Identity.Name!</b>
|
|
<p>@authMessage</p>
|
|
</Authorized>
|
|
<NotAuthorized>
|
|
<p>@authMessage</p>
|
|
<b>Hello, @context.User.Identity.Name!</b>
|
|
@* <MudText Class="mb-8">Welcome to your new app, powered by MudBlazor!</MudText>
|
|
<MudAlert Severity="Severity.Normal">You can find documentation and examples on our website here: <MudLink Href="https://mudblazor.com" Typo="Typo.body2" Color="Color.Inherit"><b>www.mudblazor.com</b></MudLink></MudAlert>*@
|
|
</NotAuthorized>
|
|
|
|
</AuthorizeView>
|
|
|
|
|
|
@code {
|
|
private string authMessage = "The user is NOT authenticated.";
|
|
|
|
[CascadingParameter]
|
|
private Task<AuthenticationState>? authenticationState { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
if (authenticationState is not null)
|
|
{
|
|
var authState = await authenticationState;
|
|
var user = authState?.User;
|
|
|
|
if (user?.Identity is not null && user.Identity.IsAuthenticated)
|
|
{
|
|
authMessage = $"{user.Identity.Name} is authenticated.";
|
|
}
|
|
}
|
|
}
|
|
} |