Добавлено управление сессиями
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user