Skip to content

Commit 0c6cfc5

Browse files
committed
feat(passkey): 添加PassKey支持并优化双重验证登录逻辑
1 parent abd9733 commit 0c6cfc5

File tree

10 files changed

+957
-51
lines changed

10 files changed

+957
-51
lines changed

app/api/apiv1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
from app.api.endpoints import login, user, webhook, message, site, subscribe, \
44
media, douban, search, plugin, tmdb, history, system, download, dashboard, \
5-
transfer, mediaserver, bangumi, storage, discover, recommend, workflow, torrent, mcp
5+
transfer, mediaserver, bangumi, storage, discover, recommend, workflow, torrent, mcp, mfa
66

77
api_router = APIRouter()
88
api_router.include_router(login.router, prefix="/login", tags=["login"])
99
api_router.include_router(user.router, prefix="/user", tags=["user"])
10+
api_router.include_router(mfa.router, prefix="/mfa", tags=["mfa"])
1011
api_router.include_router(site.router, prefix="/site", tags=["site"])
1112
api_router.include_router(message.router, prefix="/message", tags=["message"])
1213
api_router.include_router(webhook.router, prefix="/webhook", tags=["webhook"])

app/api/endpoints/login.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ def login_access_token(
2929
mfa_code=otp_password)
3030

3131
if not success:
32+
# 如果是需要MFA验证,返回特殊标识
33+
if user_or_message == "MFA_REQUIRED":
34+
raise HTTPException(
35+
status_code=401,
36+
detail="需要双重验证",
37+
headers={"X-MFA-Required": "true"}
38+
)
3239
raise HTTPException(status_code=401, detail=user_or_message)
3340

3441
# 用户等级

0 commit comments

Comments
 (0)