Updated controller with new endpoints

This commit is contained in:
Veljko Tosic
2026-02-14 18:49:44 +01:00
parent cbc27238ad
commit ccfb377e79
2 changed files with 31 additions and 4 deletions

View File

@@ -1,8 +1,10 @@
using AipsCore.Application.Abstract; using AipsCore.Application.Abstract;
using AipsCore.Application.Common.Authentication; using AipsCore.Application.Common.Authentication.Dtos;
using AipsCore.Application.Models.User.Command.LogIn; using AipsCore.Application.Models.User.Command.LogIn;
using AipsCore.Application.Models.User.Command.LogOut;
using AipsCore.Application.Models.User.Command.LogOutAll;
using AipsCore.Application.Models.User.Command.RefreshLogIn;
using AipsCore.Application.Models.User.Command.SignUp; using AipsCore.Application.Models.User.Command.SignUp;
using AipsCore.Application.Models.User.Query.GetUser;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -29,9 +31,33 @@ public class UserController : ControllerBase
[AllowAnonymous] [AllowAnonymous]
[HttpPost("login")] [HttpPost("login")]
public async Task<ActionResult<string>> LogIn(LogInUserCommand command, CancellationToken cancellationToken) public async Task<ActionResult<LogInUserResultDto>> LogIn(LogInUserCommand command, CancellationToken cancellationToken)
{ {
var result = await _dispatcher.Execute(command, cancellationToken); var result = await _dispatcher.Execute(command, cancellationToken);
return Ok(result.Value); return Ok(result);
}
[AllowAnonymous]
[HttpPost("refresh-login")]
public async Task<ActionResult<LogInUserResultDto>> RefreshLogIn(RefreshLogInCommand command, CancellationToken cancellationToken)
{
var result = await _dispatcher.Execute(command, cancellationToken);
return Ok(result);
}
[Authorize]
[HttpDelete("logout")]
public async Task<IActionResult> LogOut(LogOutCommand command, CancellationToken cancellationToken)
{
await _dispatcher.Execute(command, cancellationToken);
return Ok();
}
[Authorize]
[HttpDelete("logout-all")]
public async Task<IActionResult> LogOutAll(LogOutAllCommand command, CancellationToken cancellationToken)
{
await _dispatcher.Execute(command, cancellationToken);
return Ok();
} }
} }

View File

@@ -1,4 +1,5 @@
using AipsCore.Infrastructure.DI; using AipsCore.Infrastructure.DI;
using AipsCore.Infrastructure.Persistence.Db;
using AipsWebApi.Middleware; using AipsWebApi.Middleware;
using DotNetEnv; using DotNetEnv;