feat: account sessions and usable template editors
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
||||
from fastapi import Request, Security
|
||||
from fastapi.security import HTTPBearer
|
||||
|
||||
from pigway_frame_flow.core.accounts import session_user
|
||||
from pigway_frame_flow.errors import ErrorCode as E
|
||||
from pigway_frame_flow.errors import FlowError
|
||||
from pigway_frame_flow.storage.database import encode, now_iso
|
||||
@@ -40,6 +41,10 @@ def require(scope):
|
||||
def authorize(request: Request, credentials=Security(bearer)):
|
||||
db = request.app.state.service.db
|
||||
if not credentials:
|
||||
account = session_user(request)
|
||||
if account:
|
||||
request.state.client_id = "user:" + account["username"]
|
||||
return request.state.client_id
|
||||
raise FlowError(E.UNAUTHORIZED, "Frame Flow API token required", 401)
|
||||
digest = hashlib.sha256(credentials.credentials.encode()).hexdigest()
|
||||
for row in db.all("SELECT * FROM clients WHERE enabled=1"):
|
||||
|
||||
Reference in New Issue
Block a user