Add a cache system on the referential info
+ Add an identity service
This commit is contained in:
34
Back/skydiveLogs-api.DomainBusiness/IdentityService.cs
Normal file
34
Back/skydiveLogs-api.DomainBusiness/IdentityService.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
public class IdentityService : IIdentityService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public IdentityService(ClaimsPrincipal user)
|
||||
{
|
||||
if (user != null
|
||||
&& user.Claims.Any())
|
||||
{
|
||||
var claims = user.Claims;
|
||||
|
||||
ConnectedUser = new User();
|
||||
ConnectedUser.Login = claims.Single(c => c.Type == ClaimTypes.Name).Value;
|
||||
ConnectedUser.Id = Convert.ToInt32(claims.Single(c => c.Type == ClaimTypes.UserData).Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public User ConnectedUser { get; init; }
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user