Implement user session management and JWT refresh tokens

Added user session models, interfaces, repository, and service for managing user sessions and refresh tokens. Refactored authentication flow to return user objects and open sessions with device info, supporting refresh token generation and validation. Updated JWT configuration to separate access and refresh options, and refactored related tests and API contracts. Improved media upload handling and error logging. Migrated dependency references and DI registrations accordingly.
This commit is contained in:
Artemy
2025-07-18 20:16:36 +07:00
parent 6063aafd9e
commit ab643c16a4
48 changed files with 1860 additions and 84 deletions
@@ -0,0 +1,10 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.UserSessionsRepository;
public interface IUserSessionsExist
{
public bool Exist(Guid sessionId);
public bool Exist(string refresh);
public bool Exist(UserSession userSession);
}
@@ -0,0 +1,13 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.UserSessionsRepository;
public interface IUserSessionsReader
{
public Task<List<UserSession>> GetAllAsync();
public Task<UserSession> GetByIdAsync(Guid sessionId);
public Task<List<UserSession>> GetByUserIdAsync(Guid userId);
public Task<List<UserSession>> GetByCreatedAtAsync(DateTime createdAt);
public Task<List<UserSession>> GetByExpiresAtAsync(DateTime createdAt);
public Task<List<UserSession>> GetByRevokedAsync(bool isRevoked);
}
@@ -0,0 +1,8 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.UserSessionsRepository;
public interface IUserSessionsRepository : IUserSessionsReader, IUserSessionsWriter, IUserSessionsExist
{
}
@@ -0,0 +1,11 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.UserSessionsRepository;
public interface IUserSessionsWriter
{
Task AddAsync(UserSession userSession);
Task UpdateAsync(UserSession userSession);
Task RemoveAsync(Guid sessionId);
Task RemoveByUserIdAsync(Guid userId);
}