cookie configuration
This commit is contained in:
parent
b4edb6ae83
commit
e3c95eb109
5 changed files with 22 additions and 8 deletions
|
@ -1,14 +1,16 @@
|
|||
using Femto.Api.Auth;
|
||||
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;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Femto.Api.Controllers.Auth;
|
||||
|
||||
[ApiController]
|
||||
[Route("auth")]
|
||||
public class AuthController(IAuthModule authModule) : ControllerBase
|
||||
public class AuthController(IAuthModule authModule, IOptions<CookieSettings> cookieSettings) : ControllerBase
|
||||
{
|
||||
[HttpPost("login")]
|
||||
public async Task<ActionResult<LoginResponse>> Login([FromBody] LoginRequest request)
|
||||
|
@ -17,7 +19,7 @@ public class AuthController(IAuthModule authModule) : ControllerBase
|
|||
new LoginCommand(request.Username, request.Password)
|
||||
);
|
||||
|
||||
HttpContext.SetSession(result.Session);
|
||||
HttpContext.SetSession(result.Session, cookieSettings.Value);
|
||||
|
||||
return new LoginResponse(result.UserId, result.Username);
|
||||
}
|
||||
|
@ -29,7 +31,7 @@ public class AuthController(IAuthModule authModule) : ControllerBase
|
|||
new RegisterCommand(request.Username, request.Password)
|
||||
);
|
||||
|
||||
HttpContext.SetSession(result.Session);
|
||||
HttpContext.SetSession(result.Session, cookieSettings.Value);
|
||||
|
||||
return new RegisterResponse(result.UserId, result.Username);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue