trigger auth_state_hook prior to options form

- allow auth_state_hook to be async
- trigger it prior to start and options_form serving, rather than on home page
This commit is contained in:
Min RK
2020-01-09 13:04:45 +01:00
parent 6227f92b5f
commit 5f626268ef
3 changed files with 15 additions and 6 deletions

View File

@@ -535,12 +535,17 @@ class User:
# trigger pre-spawn hook on authenticator
authenticator = self.authenticator
try:
spawner._start_pending = True
if authenticator:
# pre_spawn_start can thow errors that can lead to a redirect loop
# if left uncaught (see https://github.com/jupyterhub/jupyterhub/issues/2683)
await maybe_future(authenticator.pre_spawn_start(self, spawner))
spawner._start_pending = True
# trigger auth_state hook
auth_state = await self.get_auth_state()
await spawner.run_auth_state_hook(auth_state)
# update spawner start time, and activity for both spawner and user
self.last_activity = (
spawner.orm_spawner.started