mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-09 11:12:28 +08:00
Initial commit
This commit is contained in:
13
src/api/base/authenticated_adapter.py
Normal file
13
src/api/base/authenticated_adapter.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from fastapi import HTTPException
|
||||
|
||||
from .adapter import ApiAdapter, ApiMode
|
||||
|
||||
|
||||
class AuthenticatedApiAdapter(ApiAdapter):
|
||||
"""通用需要登录的适配器基类。"""
|
||||
|
||||
mode = ApiMode.USER
|
||||
|
||||
def authorize(self, context): # type: ignore[override]
|
||||
if not context.user:
|
||||
raise HTTPException(status_code=401, detail="未登录")
|
||||
Reference in New Issue
Block a user