- Improved directory structure
- Added functional and unit tests
This commit is contained in:
2022-03-30 10:46:54 +02:00
parent e27e2175b5
commit 21d2bc334c
33 changed files with 1782 additions and 238 deletions

21
api/app/auth.py Normal file
View File

@@ -0,0 +1,21 @@
from flask import current_app
import jwt
from apiflask import HTTPTokenAuth
auth = HTTPTokenAuth()
@auth.verify_token
def verify_token(token):
if token is None:
return False
if ':' in token: # Bot token
token = token.split(":")[0]
try:
jwt.decode(token, current_app.config['SECRET_KEY'], algorithms=["HS256"])
return True
except jwt.PyJWTError:
return False