Tokens are validated in respective endpoints
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -15,12 +13,11 @@ namespace Icarus.Controllers.V1
|
||||
{
|
||||
[Route("api/v1/artist")]
|
||||
[ApiController]
|
||||
public class ArtistController : ControllerBase
|
||||
public class ArtistController : BaseController
|
||||
{
|
||||
#region Fields
|
||||
private readonly ILogger<ArtistController> _logger;
|
||||
private string _connectionString;
|
||||
private IConfiguration _config;
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -40,9 +37,13 @@ namespace Icarus.Controllers.V1
|
||||
|
||||
#region HTTP Routes
|
||||
[HttpGet]
|
||||
[Authorize("read:artists")]
|
||||
public IActionResult Get()
|
||||
{
|
||||
if (!IsTokenValid("read:artists"))
|
||||
{
|
||||
return StatusCode(401, "Not allowed");
|
||||
}
|
||||
|
||||
var artistContext = new ArtistContext(_connectionString);
|
||||
|
||||
var artists = artistContext.Artists.ToList();
|
||||
@@ -54,9 +55,13 @@ namespace Icarus.Controllers.V1
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Authorize("read:artists")]
|
||||
public IActionResult Get(int id)
|
||||
{
|
||||
if (!IsTokenValid("read:artists"))
|
||||
{
|
||||
return StatusCode(401, "Not allowed");
|
||||
}
|
||||
|
||||
Artist artist = new Artist
|
||||
{
|
||||
ArtistID = id
|
||||
|
||||
Reference in New Issue
Block a user