mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Fix remove and enable issues with non-last-admin
"Remove" issue likely due to multiple context instances. "Enable" issue due to conditional check. Discovered bug with users when first disabling, then marking as admin, which remains an issue.
This commit is contained in:
parent
f2aa4d4484
commit
a443426d83
@ -109,6 +109,7 @@ namespace BTCPayServer.Services
|
|||||||
|
|
||||||
await Task.WhenAll(files.Select(file => _fileService.RemoveFile(file.Id, userId)));
|
await Task.WhenAll(files.Select(file => _fileService.RemoveFile(file.Id, userId)));
|
||||||
|
|
||||||
|
user = await _userManager.FindByIdAsync(userId);
|
||||||
await _userManager.DeleteAsync(user);
|
await _userManager.DeleteAsync(user);
|
||||||
await _storeRepository.CleanUnreachableStores();
|
await _storeRepository.CleanUnreachableStores();
|
||||||
}
|
}
|
||||||
@ -127,7 +128,12 @@ namespace BTCPayServer.Services
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Count(applicationUser => !IsDisabled(applicationUser)) == 1;
|
var adminUsers = await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin);
|
||||||
|
var enabledAdminUsers = adminUsers
|
||||||
|
.Where(applicationUser => !IsDisabled(applicationUser))
|
||||||
|
.Select(applicationUser => applicationUser.Id).ToList();
|
||||||
|
|
||||||
|
return enabledAdminUsers.Count == 1 && enabledAdminUsers.Contains(user.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user