mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 14:33:00 +00:00
only add current user as admin if no other admin users
handles case where admin could be loaded from db
This commit is contained in:
@@ -263,8 +263,8 @@ class JupyterHubApp(Application):
|
|||||||
)
|
)
|
||||||
db = Any()
|
db = Any()
|
||||||
|
|
||||||
admin_users = Set({getpass.getuser()}, config=True,
|
admin_users = Set(config=True,
|
||||||
help="""list of usernames of admin users
|
help="""set of usernames of admin users
|
||||||
|
|
||||||
If unspecified, only the user that launches the server will be admin.
|
If unspecified, only the user that launches the server will be admin.
|
||||||
"""
|
"""
|
||||||
@@ -380,6 +380,12 @@ class JupyterHubApp(Application):
|
|||||||
"""Load users into and from the database"""
|
"""Load users into and from the database"""
|
||||||
db = self.db
|
db = self.db
|
||||||
|
|
||||||
|
if not self.admin_users:
|
||||||
|
# add current user as admin if there aren't any others
|
||||||
|
admins = db.query(orm.User).filter(orm.User.admin==True)
|
||||||
|
if admins.first() is None:
|
||||||
|
self.admin_users.add(getpass.getuser())
|
||||||
|
|
||||||
for name in self.admin_users:
|
for name in self.admin_users:
|
||||||
# ensure anyone specified as admin in config is admin in db
|
# ensure anyone specified as admin in config is admin in db
|
||||||
user = orm.User.find(db, name)
|
user = orm.User.find(db, name)
|
||||||
|
Reference in New Issue
Block a user