session
This commit is contained in:
parent
baea64229b
commit
0dc41337da
36 changed files with 324 additions and 95 deletions
|
@ -1,4 +1,7 @@
|
|||
using Femto.Modules.Authentication.Application;
|
||||
using Femto.Api.Sessions;
|
||||
using Femto.Modules.Auth.Application;
|
||||
using Femto.Modules.Auth.Application.Commands.Login;
|
||||
using Femto.Modules.Auth.Application.Commands.Register;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Femto.Api.Controllers.Auth;
|
||||
|
@ -10,23 +13,31 @@ public class AuthController(IAuthenticationModule authModule) : ControllerBase
|
|||
[HttpPost("login")]
|
||||
public async Task<ActionResult<LoginResponse>> Login([FromBody] LoginRequest request)
|
||||
{
|
||||
|
||||
var userId = await authModule.PostCommand(new LoginCommand(request.Username, request.Password));
|
||||
var result = await authModule.PostCommand(
|
||||
new LoginCommand(request.Username, request.Password)
|
||||
);
|
||||
|
||||
HttpContext.SetSession(result.Session);
|
||||
|
||||
throw new NotImplementedException();
|
||||
return new LoginResponse(result.UserId, result.Username);
|
||||
}
|
||||
|
||||
[HttpPost("signup")]
|
||||
public async Task<ActionResult<SignupResponse>> Signup([FromBody] SignupRequest request)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var result = await authModule.PostCommand(
|
||||
new RegisterCommand(request.Username, request.Password)
|
||||
);
|
||||
|
||||
HttpContext.SetSession(result.Session);
|
||||
|
||||
return new SignupResponse(result.UserId, result.Username);
|
||||
}
|
||||
|
||||
[HttpPost("delete-session")]
|
||||
public async Task<ActionResult> DeleteSession([FromBody] DeleteSessionRequest request)
|
||||
{
|
||||
// TODO
|
||||
return Ok(new {});
|
||||
return Ok(new { });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue