@@ -48,15 +48,15 @@ def _redirect_safe(self, url, default=None):
4848 # OR pass our cross-origin check
4949 if parsed .netloc :
5050 # if full URL, run our cross-origin check:
51- origin = '%s ://%s' % ( parsed .scheme , parsed . netloc )
51+ origin = f' { parsed . scheme } ://{ parsed .netloc } '
5252 origin = origin .lower ()
5353 if self .allow_origin :
5454 allow = self .allow_origin == origin
5555 elif self .allow_origin_pat :
5656 allow = bool (self .allow_origin_pat .match (origin ))
5757 if not allow :
5858 # 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 } " )
6060 url = default
6161 self .redirect (url )
6262
@@ -73,13 +73,13 @@ def hashed_password(self):
7373
7474 def passwd_check (self , a , b ):
7575 return passwd_check (a , b )
76-
76+
7777 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+
8081
8182
82-
8383 if self .get_login_available (self .settings ):
8484 if self .passwd_check (self .hashed_password , typed_password ) and not new_password :
8585 self .set_login_cookie (self , uuid .uuid4 ().hex )
@@ -89,7 +89,7 @@ def post(self):
8989 config_dir = self .settings .get ('config_dir' )
9090 config_file = os .path .join (config_dir , 'jupyter_notebook_config.json' )
9191 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 } " )
9393 else :
9494 self .set_status (401 )
9595 self ._render (message = {'error' : 'Invalid credentials' })
@@ -197,7 +197,7 @@ def get_user(cls, handler):
197197 @classmethod
198198 def get_user_token (cls , handler ):
199199 """Identify the user based on a token in the URL or Authorization header
200-
200+
201201 Returns:
202202 - uuid if authenticated
203203 - None if not
@@ -245,7 +245,7 @@ def password_from_settings(cls, settings):
245245
246246 If there is no configured password, an empty string will be returned.
247247 """
248- return settings .get ('password' , u '' )
248+ return settings .get ('password' , '' )
249249
250250 @classmethod
251251 def get_login_available (cls , settings ):
0 commit comments