Плеер

This commit is contained in:
FrigaT
2026-04-14 04:14:47 +03:00
parent fbfc6990e6
commit 41e0fd0563
12 changed files with 591 additions and 13 deletions

View File

@@ -46,4 +46,29 @@ public class JwtService
return (tokenString, refreshToken, tokenDescriptor.Expires.Value);
}
public ClaimsPrincipal? ValidateToken(string token)
{
var tokenHandler = new JwtSecurityTokenHandler();
var key = Encoding.UTF8.GetBytes(_configuration["Jwt:Key"]!);
try
{
var principal = tokenHandler.ValidateToken(token, new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(key),
ValidateIssuer = true,
ValidIssuer = _configuration["Jwt:Issuer"],
ValidateAudience = true,
ValidAudience = _configuration["Jwt:Audience"],
ValidateLifetime = true,
ClockSkew = TimeSpan.Zero
}, out _);
return principal;
}
catch
{
return null;
}
}
}