From 5a6d7556af4df3d76b36c8f7591de3bdf0ed54e4 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 17 Oct 2016 14:31:27 +0200 Subject: [PATCH] allow entering login token at password prompt --- notebook/auth/login.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notebook/auth/login.py b/notebook/auth/login.py index 566f55d42..5c0450f42 100644 --- a/notebook/auth/login.py +++ b/notebook/auth/login.py @@ -70,6 +70,8 @@ class LoginHandler(IPythonHandler): if self.get_login_available(self.settings): if passwd_check(self.hashed_password, typed_password): self.set_login_cookie(self, uuid.uuid4().hex) + elif self.login_token and self.login_token == typed_password: + self.set_login_cookie(self, uuid.uuid4().hex) else: self.set_status(401) self._render(message={'error': 'Invalid password'}) @@ -160,4 +162,4 @@ class LoginHandler(IPythonHandler): @classmethod def get_login_available(cls, settings): """Whether this LoginHandler is needed - and therefore whether the login page should be displayed.""" - return bool(cls.password_from_settings(settings)) + return bool(cls.password_from_settings(settings) or settings.get('login_token'))