Improved try-excepts

This commit is contained in:
Administrator 2022-03-27 20:03:11 +02:00
parent cc131a894b
commit c338e8f959
2 changed files with 4 additions and 4 deletions

View File

@ -17,5 +17,5 @@ def verify_token(token):
try:
jwt.decode(token, os.getenv('SECRET_KEY'), algorithms=["HS256"])
return True
except:
except jwt.PyJWTError:
return False

View File

@ -32,7 +32,7 @@ def extract_token_data(token):
if token is not None:
try:
return jwt.decode(token, os.getenv('SECRET_KEY'), algorithms=["HS256"])
except:
except jwt.PyJWTError:
return None
else:
return None
@ -52,13 +52,13 @@ def get_email_from_token_data():
return email
else:
return None
except:
except jwt.PyJWTError:
return None
else: # "Normal" token, extract username from token
try:
return jwt.decode(token, os.getenv('SECRET_KEY'), algorithms=["HS256"])['email']
except:
except jwt.PyJWTError:
return None
return None