mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 08:56:33 +00:00
fix cache issue
This commit is contained in:
@@ -11,28 +11,22 @@ namespace Azaion.Services;
|
||||
|
||||
public interface IAuthService
|
||||
{
|
||||
Guid? GetCurrentUserId();
|
||||
Task<User?> GetCurrentUser();
|
||||
Task<User?> GetCurrentUser();
|
||||
string CreateToken(User user);
|
||||
}
|
||||
|
||||
public class AuthService(IHttpContextAccessor httpContextAccessor, IOptions<JwtConfig> jwtConfig, IUserService userService) : IAuthService
|
||||
{
|
||||
|
||||
public Guid? GetCurrentUserId()
|
||||
private string? GetCurrentUserEmail()
|
||||
{
|
||||
var claims = httpContextAccessor.HttpContext?.User.Claims.ToDictionary(x => x.Type);
|
||||
if (claims == null)
|
||||
return null;
|
||||
|
||||
var id = Guid.Parse(claims[ClaimTypes.NameIdentifier].Value);
|
||||
return id;
|
||||
return claims?[ClaimTypes.Name].Value;
|
||||
}
|
||||
|
||||
public async Task<User?> GetCurrentUser()
|
||||
{
|
||||
var id = GetCurrentUserId();
|
||||
return await userService.GetById(id);
|
||||
var email = GetCurrentUserEmail();
|
||||
return await userService.GetByEmail(email);
|
||||
}
|
||||
|
||||
public string CreateToken(User user)
|
||||
|
||||
Reference in New Issue
Block a user