Add KeyError check
This commit is contained in:
parent
1226cbbf11
commit
913980a027
|
@ -30,16 +30,19 @@ hub:
|
|||
spawner.environment['NEXTCLOUD_ACCESS_TOKEN'] = access_token
|
||||
|
||||
async def refresh_user(self, user, handler=None):
|
||||
access_token = self.user_dict[user.name]['access_token']
|
||||
refresh_token = self.user_dict[user.name]['refresh_token']
|
||||
token_response = self.user_dict[user.name]['token_response']
|
||||
now = time.time()
|
||||
expires = self.user_dict[user.name]['token_expires']
|
||||
if now >= expires:
|
||||
print(f'Time is: {now}, token expired: {expires}')
|
||||
try:
|
||||
access_token = self.user_dict[user.name]['access_token']
|
||||
refresh_token = self.user_dict[user.name]['refresh_token']
|
||||
token_response = self.user_dict[user.name]['token_response']
|
||||
now = time.time()
|
||||
expires = self.user_dict[user.name]['token_expires']
|
||||
if now >= expires:
|
||||
print(f'Time is: {now}, token expired: {expires}')
|
||||
return False
|
||||
print(f'Time is: {now}, token expires: {expires}')
|
||||
return True
|
||||
except KeyError:
|
||||
return False
|
||||
print(f'Time is: {now}, token expires: {expires}')
|
||||
return True
|
||||
|
||||
c.JupyterHub.authenticator_class = NextcloudOAuthenticator
|
||||
c.NextcloudOAuthenticator.client_id = os.environ['NEXTCLOUD_CLIENT_ID']
|
||||
|
|
Loading…
Reference in a new issue