fix jwt token decoding; correctly import google auth routes; adjust app/auth/ package

This commit is contained in:
2026-05-19 22:21:27 +08:00
parent 419af38684
commit fe1fde778f
6 changed files with 85 additions and 29 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
from fastapi import Request, HTTPException
import os
from . import jwt
from .jwt import decode_token
JWT_SECRET = os.getenv("JWT_SECRET")
JWT_ALGORITHM = os.getenv("JWT_ALGORITHM", "HS256")
@@ -13,7 +13,7 @@ def get_current_user(request: Request):
raise HTTPException(status_code=401, detail="Not authenticated")
try:
payload = jwt.decode(token, JWT_SECRET, algorithms=[JWT_ALGORITHM])
return payload["user_id"]
payload = decode_token(token, JWT_SECRET, algorithms=[JWT_ALGORITHM])
return payload["sub"]
except:
raise HTTPException(status_code=401, detail="Invalid token")