Tokens are validated in respective endpoints

This commit is contained in:
Kun Deng
2022-08-27 21:35:49 -04:00
parent 665407aac5
commit f8ec65fd29
9 changed files with 126 additions and 115 deletions
@@ -19,11 +19,10 @@ namespace Icarus.Controllers.V1
{
[Route("api/v1/song/compressed/data")]
[ApiController]
public class SongCompressedDataController : ControllerBase
public class SongCompressedDataController : BaseController
{
#region Fields
private string _connectionString;
private IConfiguration _config;
private string _songTempDir;
private string _archiveDir;
#endregion
@@ -46,9 +45,13 @@ namespace Icarus.Controllers.V1
#region API Routes
[HttpGet("{id}")]
[Authorize("download:songs")]
public async Task<IActionResult> Get(int id)
{
if (!IsTokenValid("download:songs"))
{
return StatusCode(401, "Not allowed");
}
var context = new SongContext(_connectionString);
SongCompression cmp = new SongCompression(_archiveDir);