CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
CslaAuthenticationStateProvider.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="CslaAuthenticationStateProvider.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Basic implementation of AuthenticationStateProvider</summary>
7//-----------------------------------------------------------------------
8using System.Security.Claims;
9using System.Threading.Tasks;
10using Microsoft.AspNetCore.Components.Authorization;
11
13{
17 public class CslaAuthenticationStateProvider : AuthenticationStateProvider
18 {
23 {
24 SetPrincipal(new ClaimsPrincipal());
25 }
26
27 private AuthenticationState AuthenticationState { get; set; }
28
33 public override Task<AuthenticationState> GetAuthenticationStateAsync()
34 {
35 return Task.FromResult(AuthenticationState);
36 }
37
42 public void SetPrincipal(ClaimsPrincipal principal)
43 {
44 AuthenticationState = new AuthenticationState(principal);
45 NotifyAuthenticationStateChanged(Task.FromResult(AuthenticationState));
46 }
47 }
48}
override Task< AuthenticationState > GetAuthenticationStateAsync()
Gets the authentication state.
void SetPrincipal(ClaimsPrincipal principal)
Sets the principal representing the current user identity.