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

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

@@ -14,17 +14,20 @@ public class OpenIdController : ControllerBase
private readonly UserManager<ApplicationUser> _userManager;
private readonly JwtService _jwtService;
private readonly IConfiguration _configuration;
private readonly UserSessionService _userSessionService;
public OpenIdController(
SignInManager<ApplicationUser> signInManager,
UserManager<ApplicationUser> userManager,
JwtService jwtService,
IConfiguration configuration)
IConfiguration configuration,
UserSessionService userSessionService)
{
_signInManager = signInManager;
_userManager = userManager;
_jwtService = jwtService;
_configuration = configuration;
_userSessionService = userSessionService;
}
[HttpGet("login")]
@@ -70,6 +73,7 @@ public class OpenIdController : ControllerBase
}
await _signInManager.SignInAsync(user, isPersistent: false);
await _userSessionService.GetOrCreateCurrentSessionAsync(user.Id);
var (token, refreshToken, _) = await _jwtService.GenerateTokenAsync(user);
return Redirect($"{_configuration["Client:BaseUrl"]}/auth-callback?token={token}&refreshToken={refreshToken}");
}