From fb2803789e012cda1aca4c5f8bef779923f5db61 Mon Sep 17 00:00:00 2001 From: transtrike Date: Wed, 16 Dec 2020 19:00:00 +0200 Subject: Authorization fixed --- src/DevHive.Web/Controllers/RoleController.cs | 2 ++ src/DevHive.Web/Controllers/UserController.cs | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/DevHive.Web/Controllers') diff --git a/src/DevHive.Web/Controllers/RoleController.cs b/src/DevHive.Web/Controllers/RoleController.cs index 1e11ee1..610d370 100644 --- a/src/DevHive.Web/Controllers/RoleController.cs +++ b/src/DevHive.Web/Controllers/RoleController.cs @@ -6,11 +6,13 @@ using DevHive.Web.Models.Identity.Role; using AutoMapper; using DevHive.Services.Models.Identity.Role; using System; +using Microsoft.AspNetCore.Authorization; namespace DevHive.Web.Controllers { [ApiController] [Route("/api/[controller]")] + //[Authorize(Roles = "Admin")] public class RoleController { private readonly RoleService _roleService; diff --git a/src/DevHive.Web/Controllers/UserController.cs b/src/DevHive.Web/Controllers/UserController.cs index f952355..80e1bde 100644 --- a/src/DevHive.Web/Controllers/UserController.cs +++ b/src/DevHive.Web/Controllers/UserController.cs @@ -14,6 +14,7 @@ namespace DevHive.Web.Controllers { [ApiController] [Route("/api/[controller]")] + [Authorize(Roles = "User")] public class UserController: ControllerBase { private readonly UserService _userService; @@ -27,6 +28,7 @@ namespace DevHive.Web.Controllers [HttpPost] [Route("Login")] + [AllowAnonymous] public async Task Login([FromBody] LoginWebModel loginModel) { LoginServiceModel loginServiceModel = this._userMapper.Map(loginModel); @@ -39,6 +41,7 @@ namespace DevHive.Web.Controllers [HttpPost] [Route("Register")] + [AllowAnonymous] public async Task Register([FromBody] RegisterWebModel registerModel) { RegisterServiceModel registerServiceModel = this._userMapper.Map(registerModel); @@ -61,7 +64,6 @@ namespace DevHive.Web.Controllers //Update [HttpPut] - [Authorize(Roles = Role.DefaultRole)] public async Task Update(Guid id, [FromBody] UpdateUserWebModel updateModel) { UpdateUserServiceModel updateUserServiceModel = this._userMapper.Map(updateModel); @@ -76,7 +78,6 @@ namespace DevHive.Web.Controllers //Delete [HttpDelete] - [Authorize(Roles = Role.DefaultRole)] public async Task Delete(Guid id) { await this._userService.DeleteUser(id); -- cgit v1.2.3