Skip to content

Instantly share code, notes, and snippets.

@mattruma mattruma/Authentication.razor Secret

Created Jul 3, 2020
Embed
What would you like to do?
Adventures with Blazor: Login and Logout Events
@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
You can’t perform that action at this time.