Добавлено управление сессиями

This commit is contained in:
FrigaT
2026-04-14 01:39:25 +03:00
parent 40ea9166d2
commit fbfc6990e6
22 changed files with 1509 additions and 51 deletions

View File

@@ -13,12 +13,14 @@ public class AccountController : ControllerBase
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly JwtService _jwtService;
private readonly UserSessionService _userSessionService;
public AccountController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager, JwtService jwtService)
public AccountController(UserManager<ApplicationUser> userManager, SignInManager<ApplicationUser> signInManager, JwtService jwtService, UserSessionService userSessionService)
{
_userManager = userManager;
_signInManager = signInManager;
_jwtService = jwtService;
_userSessionService = userSessionService;
}
[HttpPost("register")]
@@ -56,6 +58,8 @@ public class AccountController : ControllerBase
private async Task<ActionResult<ApiResponse<LoginResponse>>> GenerateTokenResponse(ApplicationUser user)
{
await _userSessionService.GetOrCreateCurrentSessionAsync(user.Id);
var (token, refreshToken, expiration) = await _jwtService.GenerateTokenAsync(user);
return Ok(ApiResponse<LoginResponse>.Ok(new LoginResponse
{