@@ -48,15 +48,15 @@ def _redirect_safe(self, url, default=None):
48
48
# OR pass our cross-origin check
49
49
if parsed .netloc :
50
50
# if full URL, run our cross-origin check:
51
- origin = '%s ://%s' % ( parsed .scheme , parsed . netloc )
51
+ origin = f' { parsed . scheme } ://{ parsed .netloc } '
52
52
origin = origin .lower ()
53
53
if self .allow_origin :
54
54
allow = self .allow_origin == origin
55
55
elif self .allow_origin_pat :
56
56
allow = bool (self .allow_origin_pat .match (origin ))
57
57
if not allow :
58
58
# not allowed, use default
59
- self .log .warning ("Not allowing login redirect to %r" % url )
59
+ self .log .warning (f "Not allowing login redirect to { url !r } " )
60
60
url = default
61
61
self .redirect (url )
62
62
@@ -73,13 +73,13 @@ def hashed_password(self):
73
73
74
74
def passwd_check (self , a , b ):
75
75
return passwd_check (a , b )
76
-
76
+
77
77
def post (self ):
78
- typed_password = self .get_argument ('password' , default = u'' )
79
- new_password = self .get_argument ('new_password' , default = u'' )
78
+ typed_password = self .get_argument ('password' , default = '' )
79
+ new_password = self .get_argument ('new_password' , default = '' )
80
+
80
81
81
82
82
-
83
83
if self .get_login_available (self .settings ):
84
84
if self .passwd_check (self .hashed_password , typed_password ) and not new_password :
85
85
self .set_login_cookie (self , uuid .uuid4 ().hex )
@@ -89,7 +89,7 @@ def post(self):
89
89
config_dir = self .settings .get ('config_dir' )
90
90
config_file = os .path .join (config_dir , 'jupyter_notebook_config.json' )
91
91
set_password (new_password , config_file = config_file )
92
- self .log .info ("Wrote hashed password to %s" % config_file )
92
+ self .log .info (f "Wrote hashed password to { config_file } " )
93
93
else :
94
94
self .set_status (401 )
95
95
self ._render (message = {'error' : 'Invalid credentials' })
@@ -197,7 +197,7 @@ def get_user(cls, handler):
197
197
@classmethod
198
198
def get_user_token (cls , handler ):
199
199
"""Identify the user based on a token in the URL or Authorization header
200
-
200
+
201
201
Returns:
202
202
- uuid if authenticated
203
203
- None if not
@@ -245,7 +245,7 @@ def password_from_settings(cls, settings):
245
245
246
246
If there is no configured password, an empty string will be returned.
247
247
"""
248
- return settings .get ('password' , u '' )
248
+ return settings .get ('password' , '' )
249
249
250
250
@classmethod
251
251
def get_login_available (cls , settings ):
0 commit comments