Class UserInfoService<TIdentityUser>
This service can be used in web applications that use Dangl.Identity for authentication ///
Inheritance
Implements
Inherited Members
Namespace: Dangl.Identity.Client.Mvc.Services
Assembly: Dangl.Identity.Client.Mvc.dll
Syntax
public class UserInfoService<TIdentityUser> : IUserInfoService where TIdentityUser : IdentityUser<Guid>, IDanglIdentityUser, new()
Type Parameters
Name | Description |
---|---|
TIdentityUser |
Constructors
| Improve this Doc View SourceUserInfoService(IHttpContextAccessor, UserManager<TIdentityUser>, IUserInfoUpdater)
This services can be used in web applications that use Dangl.Identity for authentication ///
Declaration
public UserInfoService(IHttpContextAccessor httpContextAccessor, UserManager<TIdentityUser> userManager, IUserInfoUpdater userInfoUpdater)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.AspNetCore.Http.IHttpContextAccessor | httpContextAccessor | |
Microsoft.AspNetCore.Identity.UserManager<TIdentityUser> | userManager | |
IUserInfoUpdater | userInfoUpdater |
Fields
| Improve this Doc View SourceCLIENT_CLAIM_PREFIX
This is the prefix that is present on all client claims.
Declaration
public const string CLIENT_CLAIM_PREFIX = "client_"
Field Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceClientIsAuthenticatedAsync()
Returns true if a client is authenticated. This is also true if a user is authenticated via a Jwt token generated for a client.
Declaration
public Task<bool> ClientIsAuthenticatedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
GetClientClaimsAsync()
This returns all claims prefixed with "client_" for the current principal.
Declaration
public Task<List<Claim>> GetClientClaimsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.List<System.Security.Claims.Claim>> |
GetCurrentClientIdAsync()
Returns the ClientId from the currently authenticated client
Declaration
public Task<string> GetCurrentClientIdAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
GetCurrentUserEmailAsync()
This relies on an actual user being authenticated. Will return null if no user is authenticated.
Declaration
public Task<string> GetCurrentUserEmailAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
GetCurrentUserIdAsync()
This relies on an actual user being authenticated. This will throw if no user is authenticated.
Declaration
public Task<Guid> GetCurrentUserIdAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Guid> |
GetCurrentUserIdenticonIdAsync()
This relies on an actual user being authenticated. This will throw if no user is authenticated.
Declaration
public Task<Guid> GetCurrentUserIdenticonIdAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Guid> |
GetCurrentUserNameAsync()
This relies on an actual user being authenticated. Will return null if no user is authenticated.
Declaration
public Task<string> GetCurrentUserNameAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
GetUserClaimsAsync()
Returns a list of all the user claims. This includes client claims that are prefixed with "client_".
Declaration
public Task<List<Claim>> GetUserClaimsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.List<System.Security.Claims.Claim>> |
UserIsAuthenticatedAsync()
Returns true if the current principal is a user. False if only a client is authenticated.
Declaration
public Task<bool> UserIsAuthenticatedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |