|
|
|
|
@ -39,15 +39,15 @@ class LoginHandler(IPythonHandler):
|
|
|
|
|
|
|
|
|
|
def post(self):
|
|
|
|
|
typed_password = self.get_argument('password', default=u'')
|
|
|
|
|
cookie_options = self.settings.get('cookie_options', {})
|
|
|
|
|
cookie_options.setdefault('httponly', True)
|
|
|
|
|
if self.login_available(self.settings):
|
|
|
|
|
if passwd_check(self.hashed_password, typed_password):
|
|
|
|
|
# tornado <4.2 have a bug that consider secure==True as soon as
|
|
|
|
|
# tornado <4.2 has a bug that considers secure==True as soon as
|
|
|
|
|
# 'secure' kwarg is passed to set_secure_cookie
|
|
|
|
|
if self.settings.get('secure_cookie', self.request.protocol == 'https'):
|
|
|
|
|
kwargs = {'secure': True}
|
|
|
|
|
else:
|
|
|
|
|
kwargs = {}
|
|
|
|
|
self.set_secure_cookie(self.cookie_name, str(uuid.uuid4()), **kwargs)
|
|
|
|
|
cookie_options.setdefault('secure', True)
|
|
|
|
|
self.set_secure_cookie(self.cookie_name, str(uuid.uuid4()), **cookie_options)
|
|
|
|
|
else:
|
|
|
|
|
self.set_status(401)
|
|
|
|
|
self._render(message={'error': 'Invalid password'})
|
|
|
|
|
|