ref: project structure
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using mws.backend.dotnet.application.Auth;
|
||||
using mws.backend.dotnet.application.Users;
|
||||
|
||||
namespace mws.backend.dotnet.api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/auth")]
|
||||
public class AuthController(ISender sender) : ControllerBase
|
||||
{
|
||||
[HttpPost("login")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<LoginResponse>> Login([FromBody] LoginRequest request, CancellationToken ct)
|
||||
{
|
||||
var response = await sender.Send(new LoginCommand(request), ct);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpGet("me")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<UserDto>> GetProfile(CancellationToken ct)
|
||||
{
|
||||
return Ok(await sender.Send(new GetProfileQuery(User.GetUserId()), ct));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user