Feat: explore apps (#196)

This commit is contained in:
John Wang
2023-05-25 15:54:45 +08:00
committed by GitHub
parent 99f7e4f277
commit 93ae18ea12
20 changed files with 1197 additions and 231 deletions

View File

@@ -42,13 +42,16 @@ def validate_and_get_site():
"""
auth_header = request.headers.get('Authorization')
if auth_header is None:
raise Unauthorized()
raise Unauthorized('Authorization header is missing.')
if ' ' not in auth_header:
raise Unauthorized('Invalid Authorization header format. Expected \'Bearer <api-key>\' format.')
auth_scheme, auth_token = auth_header.split(None, 1)
auth_scheme = auth_scheme.lower()
if auth_scheme != 'bearer':
raise Unauthorized()
raise Unauthorized('Invalid Authorization header format. Expected \'Bearer <api-key>\' format.')
site = db.session.query(Site).filter(
Site.code == auth_token,