Плеер
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,15 @@ public class YandexMusicService
|
||||
return await playlist.RemoveTracksAsync(tracks.ToArray());
|
||||
}
|
||||
|
||||
public async Task<string?> GetTrackFileUrlAsync(ApplicationUser user, string trackId)
|
||||
{
|
||||
using var client = await CreateClientAsync(user);
|
||||
if (client == null) return null;
|
||||
var track = await client.GetTrackAsync(trackId);
|
||||
if (track == null) return null;
|
||||
return await track.GetLinkAsync();
|
||||
}
|
||||
|
||||
public string EncryptToken(string token) => _dataProtector.Protect(token);
|
||||
|
||||
public string DecryptToken(string encryptedToken)
|
||||
|
||||
Reference in New Issue
Block a user