diff --git a/Govor.API/Controllers/ChatLoadController.cs b/Govor.API/Controllers/ChatLoadController.cs index 4a1fa6f..36fd42d 100644 --- a/Govor.API/Controllers/ChatLoadController.cs +++ b/Govor.API/Controllers/ChatLoadController.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc; namespace Govor.API.Controllers; [ApiController] -[Authorize] +[Authorize(Roles = "Admin, User")] [Route("api/chats")] public class ChatLoadController : Controller { @@ -49,7 +49,7 @@ public class ChatLoadController : Controller catch (UnauthorizedAccessException ex) { _logger.LogWarning(ex.Message); - return Unauthorized(ex.Message); + return Forbid(ex.Message); } catch (Exception ex) { @@ -84,7 +84,7 @@ public class ChatLoadController : Controller catch (UnauthorizedAccessException ex) { _logger.LogWarning(ex.Message); - return Unauthorized(ex.Message); + return Forbid(ex.Message); } catch (Exception ex) { diff --git a/Govor.API/Controllers/MediaController.cs b/Govor.API/Controllers/MediaController.cs index e48e45d..bec6eda 100644 --- a/Govor.API/Controllers/MediaController.cs +++ b/Govor.API/Controllers/MediaController.cs @@ -68,7 +68,7 @@ public class MediaController : Controller catch (UnauthorizedAccessException ex) { _logger.LogWarning(ex, ex.Message); - return Unauthorized(ex.Message); + return Forbid(ex.Message); } catch (InvalidOperationException ex) { diff --git a/Govor.API/Controllers/OnlinePingingController.cs b/Govor.API/Controllers/OnlinePingingController.cs index 871e960..9d54551 100644 --- a/Govor.API/Controllers/OnlinePingingController.cs +++ b/Govor.API/Controllers/OnlinePingingController.cs @@ -43,11 +43,6 @@ public class OnlinePingingController : Controller _logger.LogError(e, e.Message); return BadRequest("User can't be found in our database."); } - catch (UnauthorizedAccessException e) - { - _logger.LogError(e, e.Message); - return Forbid(e.Message); - } catch (Exception e) { _logger.LogError(e, e.Message);