mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-05-30 11:25:20 -04:00
Version Update Modal Rework + A few bugfixes (#3664)
This commit is contained in:
@@ -546,7 +546,16 @@ public class UserRepository : IUserRepository
|
||||
public async Task<IList<string>> GetRoles(int userId)
|
||||
{
|
||||
var user = await _context.Users.FirstOrDefaultAsync(u => u.Id == userId);
|
||||
if (user == null || _userManager == null) return ArraySegment<string>.Empty; // userManager is null on Unit Tests only
|
||||
if (user == null) return ArraySegment<string>.Empty;
|
||||
|
||||
if (_userManager == null)
|
||||
{
|
||||
// userManager is null on Unit Tests only
|
||||
return await _context.UserRoles
|
||||
.Where(ur => ur.UserId == userId)
|
||||
.Select(ur => ur.Role.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
return await _userManager.GetRolesAsync(user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user