中 | EN
Provides an Identity
implementation for the project, supports the Blazor Server
project
Example:
Install-Package Masa.Contrib.Authentication.Identity.BlazorServer
- Modify
Program.cs
builder.Services.AddMasaIdentity();
- Get user information
IUserContext userContext;//Get IUserContext from DI
userContext.User;//Get user information
- Temporarily change the current login user information
IUserSetter userSetter;//Get IUserSetter from DI
var user = new IdentityUser()
{
Id = "2",
UserName = "Tom",
Environment = "Production",
TenantId = "2"
};
using(userSetter.Change(user))
{
//The obtained user information is Tom
}