mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-05 14:25:17 -04:00
No more JWTs for Scripts + Polish (#4274)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
@@ -133,10 +133,11 @@ public interface IUserRepository
|
||||
Task<string?> GetCoverImageAsync(int userId, int requestingUserId);
|
||||
Task<string?> GetPersonCoverImageAsync(int personId);
|
||||
Task<IList<AuthKeyDto>> GetAuthKeysForUserId(int userId);
|
||||
Task<IList<AuthKeyDto>> GetAllAuthKeysDtosWithExpiration();
|
||||
Task<AppUserAuthKey?> GetAuthKeyById(int authKeyId);
|
||||
Task<DateTime?> GetAuthKeyExpiration(string authKey, int userId);
|
||||
Task<AppUserSocialPreferences> GetSocialPreferencesForUser(int userId);
|
||||
Task<AppUserPreferences> GetPreferencesForUser(int userId);
|
||||
|
||||
}
|
||||
|
||||
public class UserRepository : IUserRepository
|
||||
@@ -970,6 +971,9 @@ public class UserRepository : IUserRepository
|
||||
return await _context.AppUserAuthKey
|
||||
.Where(k => k.Key == authKey)
|
||||
.HasNotExpired()
|
||||
.Include(k => k.AppUser)
|
||||
.ThenInclude(u => u.UserRoles)
|
||||
.ThenInclude(ur => ur.Role)
|
||||
.Select(k => k.AppUser)
|
||||
.ProjectTo<UserDto>(_mapper.ConfigurationProvider)
|
||||
.FirstOrDefaultAsync();
|
||||
@@ -1073,6 +1077,14 @@ public class UserRepository : IUserRepository
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IList<AuthKeyDto>> GetAllAuthKeysDtosWithExpiration()
|
||||
{
|
||||
return await _context.AppUserAuthKey
|
||||
.Where(k => k.ExpiresAtUtc != null)
|
||||
.ProjectTo<AuthKeyDto>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<AppUserAuthKey?> GetAuthKeyById(int authKeyId)
|
||||
{
|
||||
return await _context.AppUserAuthKey
|
||||
@@ -1080,6 +1092,14 @@ public class UserRepository : IUserRepository
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<DateTime?> GetAuthKeyExpiration(string authKey, int userId)
|
||||
{
|
||||
return await _context.AppUserAuthKey
|
||||
.Where(k => k.Key == authKey && k.AppUserId == userId)
|
||||
.Select(k => k.ExpiresAtUtc)
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<AppUserSocialPreferences> GetSocialPreferencesForUser(int userId)
|
||||
{
|
||||
return await _context.AppUserPreferences
|
||||
|
||||
Reference in New Issue
Block a user