Плеер

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;
}
}
}

View File

@@ -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)