Merge pull request #26 from WebEngineering2/try_except_fix

Try except fix
This commit is contained in:
Florian Kaiser 2022-03-27 20:15:06 +02:00 committed by GitHub
commit 2a87970cb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 23 deletions

View File

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

View File

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

View File

@ -60,16 +60,31 @@ class KeywordSchema(Schema):
keyword = String() keyword = String()
class SymbolSchema(Schema):
symbol = String()
class TransactionSchema(Schema):
symbol = String()
time = String(validate=validate.Regexp(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z"))
count = Integer()
price = Float()
class TelegramIdSchema(Schema):
telegram_user_id = String()
class DeleteSuccessfulSchema(Schema):
pass
class KeywordResponseSchema(Schema): class KeywordResponseSchema(Schema):
keyword = String() keyword = String()
s_id = Integer() s_id = Integer()
email = Email() email = Email()
class SymbolSchema(Schema):
symbol = String()
class SymbolResponseSchema(Schema): class SymbolResponseSchema(Schema):
symbol = String() symbol = String()
s_id = Integer() s_id = Integer()
@ -81,13 +96,6 @@ class PortfolioShareResponseSchema(Schema):
last_transaction = String() last_transaction = String()
class TransactionSchema(Schema):
symbol = String()
time = String(validate=validate.Regexp(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z"))
count = Integer()
price = Float()
class TransactionResponseSchema(Schema): class TransactionResponseSchema(Schema):
email = Email() email = Email()
symbol = String() symbol = String()
@ -96,16 +104,8 @@ class TransactionResponseSchema(Schema):
price = Float() price = Float()
class TelegramIdSchema(Schema):
telegram_user_id = String()
class PortfolioResponseSchema(Schema): class PortfolioResponseSchema(Schema):
symbol = String() symbol = String()
last_transaction = String() last_transaction = String()
count = Integer() count = Integer()
# price = Float() # price = Float()
class DeleteSuccessfulSchema(Schema):
pass