Updated controller with new endpoints
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
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.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.Query.GetUser;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -29,9 +31,33 @@ public class UserController : ControllerBase
|
||||
|
||||
[AllowAnonymous]
|
||||
[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);
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using AipsCore.Infrastructure.DI;
|
||||
using AipsCore.Infrastructure.Persistence.Db;
|
||||
using AipsWebApi.Middleware;
|
||||
using DotNetEnv;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user