Add UserRole handling
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Security.Claims;
|
||||
using Imprink.Application.Users;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Imprink.WebApi.Controllers.Users;
|
||||
@@ -9,7 +10,7 @@ namespace Imprink.WebApi.Controllers.Users;
|
||||
[Route("/api/users/roles")]
|
||||
public class UserRoleController(IMediator mediator) : ControllerBase
|
||||
{
|
||||
//[Authorize]
|
||||
[Authorize]
|
||||
[HttpGet("me")]
|
||||
public async Task<IActionResult> GetMyRoles()
|
||||
{
|
||||
@@ -20,4 +21,16 @@ public class UserRoleController(IMediator mediator) : ControllerBase
|
||||
|
||||
return Ok(myRoles);
|
||||
}
|
||||
|
||||
[Authorize(Roles = "Admin")]
|
||||
[HttpPost("set")]
|
||||
public async Task<IActionResult> SetUserRole(SetUserRoleCommand command)
|
||||
{
|
||||
var userRole = await mediator.Send(command);
|
||||
|
||||
if (userRole == null)
|
||||
return BadRequest();
|
||||
|
||||
return Ok(userRole);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user