authentication refresh fixed, movie creation page added
This commit is contained in:
@@ -85,21 +85,24 @@ public class TokensService(DatabaseContext database, IConfigurationService confi
|
||||
return TokenToString(tokenDescriptor);
|
||||
}
|
||||
|
||||
protected SecurityTokenDescriptor CreateBaseSecurityTokenDescriptor(Account account, Guid id, DateTime expirationTime) => new SecurityTokenDescriptor
|
||||
protected SecurityTokenDescriptor CreateBaseSecurityTokenDescriptor(Account account, Guid id, DateTime expirationTime)
|
||||
{
|
||||
Subject = new ClaimsIdentity(new List<Claim>
|
||||
return new SecurityTokenDescriptor
|
||||
{
|
||||
new Claim(JwtRegisteredClaimNames.Jti, id.ToString()),
|
||||
new Claim(JwtRegisteredClaimNames.Sub, account.Id.ToString()),
|
||||
new Claim(JwtRegisteredClaimNames.Email, account.Email),
|
||||
new Claim(JwtRegisteredClaimNames.UniqueName, account.Username),
|
||||
new Claim(JwtRegisteredClaimNames.Exp, expirationTime.Ticks.ToString()),
|
||||
new Claim("admin", account.IsAdmin.ToString()),
|
||||
}),
|
||||
Expires = expirationTime,
|
||||
Issuer = configurationService.Data.Authentication.Issuer,
|
||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configurationService.Data.Authentication.Key)), SecurityAlgorithms.HmacSha512)
|
||||
};
|
||||
Subject = new ClaimsIdentity(new List<Claim>
|
||||
{
|
||||
new Claim(JwtRegisteredClaimNames.Jti, id.ToString()),
|
||||
new Claim(JwtRegisteredClaimNames.Sub, account.Id.ToString()),
|
||||
new Claim(JwtRegisteredClaimNames.Email, account.Email),
|
||||
new Claim(JwtRegisteredClaimNames.UniqueName, account.Username),
|
||||
new Claim(JwtRegisteredClaimNames.Exp, expirationTime.Ticks.ToString()),
|
||||
new Claim("admin", account.IsAdmin.ToString()),
|
||||
}),
|
||||
Expires = expirationTime,
|
||||
Issuer = configurationService.Data.Authentication.Issuer,
|
||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configurationService.Data.Authentication.Key)), SecurityAlgorithms.HmacSha512)
|
||||
};
|
||||
}
|
||||
|
||||
protected string TokenToString(SecurityTokenDescriptor tokenDescriptor)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,15 @@ public class UserService(DatabaseContext database, IHttpContextAccessor accessor
|
||||
return accessor.HttpContext.User;
|
||||
}
|
||||
|
||||
public string? GetRawToken()
|
||||
{
|
||||
if (accessor.HttpContext is null)
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
return accessor.HttpContext.Request.Headers.Authorization;
|
||||
}
|
||||
|
||||
public UserValidator GetValidator()
|
||||
{
|
||||
ClaimsPrincipal rawUser = GetRawUser();
|
||||
|
||||
Reference in New Issue
Block a user