raise 500 on failure to identify a user in oauth callback

This commit is contained in:
Min RK
2017-04-21 14:52:23 +02:00
parent 66cb630b86
commit c3a90e0804
2 changed files with 6 additions and 1 deletions

View File

@@ -638,6 +638,8 @@ class HubOAuthCallbackHandler(HubOAuthenticated, RequestHandler):
# TODO: make async (in a Thread?)
token = self.hub_auth.token_for_code(code)
user_model = self.hub_auth.user_for_token(token)
if user_model is None:
raise HTTPError(500, "oauth callback failed to identify a user")
app_log.info("Logged-in user %s", user_model)
self.hub_auth.set_cookie(self, token)
next_url = self.get_argument('next', '') or self.hub_auth.base_url