Make isAdmin async
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Managing.Application.Shared;
|
||||
|
||||
public interface IAdminConfigurationService
|
||||
{
|
||||
bool IsUserAdmin(string userName);
|
||||
Task<bool> IsUserAdminAsync(string userName);
|
||||
List<string> GetAdminUserNames();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class AdminConfigurationService : IAdminConfigurationService
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
}
|
||||
|
||||
public bool IsUserAdmin(string userName)
|
||||
public async Task<bool> IsUserAdminAsync(string userName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userName))
|
||||
{
|
||||
@@ -50,7 +50,7 @@ public class AdminConfigurationService : IAdminConfigurationService
|
||||
using var scope = _serviceScopeFactory.CreateScope();
|
||||
var userRepository = scope.ServiceProvider.GetRequiredService<IUserRepository>();
|
||||
|
||||
var user = userRepository.GetUserByNameAsync(userName).GetAwaiter().GetResult();
|
||||
var user = await userRepository.GetUserByNameAsync(userName);
|
||||
|
||||
if (user != null && user.IsAdmin)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user