mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 14:33:00 +00:00
Call Authenticator.add_user for new users at startup
Ensures consistency between users created from config and from REST API
This commit is contained in:
@@ -460,11 +460,14 @@ class JupyterHub(Application):
|
|||||||
if admins.first() is None:
|
if admins.first() is None:
|
||||||
self.admin_users.add(getuser())
|
self.admin_users.add(getuser())
|
||||||
|
|
||||||
|
new_users = []
|
||||||
|
|
||||||
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)
|
||||||
if user is None:
|
if user is None:
|
||||||
user = orm.User(name=name, admin=True)
|
user = orm.User(name=name, admin=True)
|
||||||
|
new_users.append(user)
|
||||||
db.add(user)
|
db.add(user)
|
||||||
else:
|
else:
|
||||||
user.admin = True
|
user.admin = True
|
||||||
@@ -482,6 +485,7 @@ class JupyterHub(Application):
|
|||||||
user = orm.User.find(db, name)
|
user = orm.User.find(db, name)
|
||||||
if user is None:
|
if user is None:
|
||||||
user = orm.User(name=name)
|
user = orm.User(name=name)
|
||||||
|
new_users.append(user)
|
||||||
db.add(user)
|
db.add(user)
|
||||||
|
|
||||||
if whitelist:
|
if whitelist:
|
||||||
@@ -498,6 +502,9 @@ class JupyterHub(Application):
|
|||||||
# to the whitelist set and user db, unless the whitelist is empty (all users allowed).
|
# to the whitelist set and user db, unless the whitelist is empty (all users allowed).
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
for user in new_users:
|
||||||
|
self.authenticator.add_user(user)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
# load any still-active spawners from JSON
|
# load any still-active spawners from JSON
|
||||||
run_sync = IOLoop().run_sync
|
run_sync = IOLoop().run_sync
|
||||||
|
Reference in New Issue
Block a user