mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-05 21:37:10 -04:00
don't allow removal of admin rights if there is only one admin
This commit is contained in:
parent
ca3f804db6
commit
41e3b2fb3a
@ -285,6 +285,15 @@ namespace MediaBrowser.Api
|
||||
|
||||
var user = _userManager.GetUserById(id);
|
||||
|
||||
// If removing admin access
|
||||
if (!dtoUser.Configuration.IsAdministrator && user.Configuration.IsAdministrator)
|
||||
{
|
||||
if (_userManager.Users.Count(i => i.Configuration.IsAdministrator) == 1)
|
||||
{
|
||||
throw new ArgumentException("There must be at least one user in the system with administrative access.");
|
||||
}
|
||||
}
|
||||
|
||||
var task = user.Name.Equals(dtoUser.Name, StringComparison.Ordinal) ? _userManager.UpdateUser(user) : _userManager.RenameUser(user, dtoUser.Name);
|
||||
|
||||
Task.WaitAll(task);
|
||||
|
Loading…
Reference in New Issue
Block a user