-
-
Save mattruma/e4cc5dce47894f4edb12c18f37aebfca to your computer and use it in GitHub Desktop.
Adventures with Blazor: Login and Logout Events
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
@page "/authentication/{action}" | |
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | |
@using System.Threading.Tasks | |
<RemoteAuthenticatorView Action="@Action" OnLogOutSucceeded=@this.OnLogOutSucceeded OnLogInSucceeded=@this.OnLogInSucceeded /> | |
@code{ | |
[Parameter] | |
public string Action { get; set; } | |
[CascadingParameter] | |
public Task<AuthenticationState> AuthenticationState { get; set; } | |
public async void OnLogInSucceeded() | |
{ | |
var user = | |
(await AuthenticationState).User; | |
if (user.Identity.IsAuthenticated) | |
{ | |
// Do some stuff | |
} | |
} | |
public void OnLogOutSucceeded() | |
{ | |
// Do some stuff | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment