⚠ Deprecated: Legacy
Suggested alternative: Alva.ServiceKit.IdentityService
The helper class and interface for getting information about an authorized user. Included in the general set of auxiliary libraries: Alva.ServiceKit.*
License
—
Deps
1
Install Size
—
Vulns
✓ 0
Published
Feb 26, 2023
Get Started
$ dotnet add package ServiceKit.IdentityServiceReadme
ServiceKit.IdentityService
Вспомогательный класс и интерфейс для получения информации об авторизированном пользователе. Входит в состав общего набора вспомогательных библиотек: Alva.ServiceKit.*
Interface
public interface IUserService
{
public string GetCurrentUserName();
public ClaimsPrincipal GetCurrentUser();
}
Implementation
public string GetCurrentUserName()
{
return _context.HttpContext?.User?.Identity?.Name;
}
public ClaimsPrincipal GetCurrentUser()
{
return _context.HttpContext?.User;
}