BS-001 Initialize BortStack foundation and project workflow

This commit is contained in:
rob
2026-11-10 14:02:50 +00:00
parent 1ec90a082f
commit 52265961cb
119 changed files with 10298 additions and 64 deletions
+33
View File
@@ -0,0 +1,33 @@
"""Auth."""
from flask_httpauth import HTTPBasicAuth, HTTPTokenAuth
from models import User
from errors import error_response
basic_auth = HTTPBasicAuth()
token_auth = HTTPTokenAuth()
@basic_auth.verify_password
def verify_password(email, password):
"""Verify password."""
user = User.query.filter_by(email=email).first()
if user and user.check_password(password):
return user
@basic_auth.error_handler
def basic_auth_error(status):
"""Basic auth error."""
return error_response(status)
@token_auth.verify_token
def verify_token(token):
"""Verify token."""
return User.check_token(token) if token else None
@token_auth.error_handler
def token_auth_error(status):
"""Token auth error."""
return error_response(status)