diff --git a/app/api/deps.py b/app/api/deps.py index 2d8568b..d0a17fa 100644 --- a/app/api/deps.py +++ b/app/api/deps.py @@ -10,10 +10,7 @@ async def get_current_user( access_token: Optional[str] = Cookie(None), db: Session = Depends(get_db) ) -> UserDB: - - print(f"authorization: {authorization}") - print(f"access_token: {access_token}") - + # 优先使用Header中的token,其次使用Cookie中的token token = None if authorization and authorization.startswith("Bearer "): @@ -24,8 +21,6 @@ async def get_current_user( if not token: raise HTTPException(status_code=401, detail="未提供有效的认证信息") - print(f"token: {token}") - sub = verify_token(token) if not sub: raise HTTPException(status_code=401, detail="Token已过期或无效") diff --git a/app/api/endpoints/order.py b/app/api/endpoints/order.py index ff14bb6..87c1710 100644 --- a/app/api/endpoints/order.py +++ b/app/api/endpoints/order.py @@ -910,11 +910,11 @@ async def deliveryman_orders( # 如果配送时段不为空,则使用配送时段的时间 if order.time_period_id: if order.delivery_date == datetime.now().date(): - delivery_time = f"今日 {order.time_period_name}" + delivery_time = f"{order.time_period_name}" elif order.delivery_date == datetime.now().date() + timedelta(days=1): delivery_time = f"明日 {order.time_period_name}" else: - delivery_time = f"{order.delivery_date} {order.time_period_name}" + delivery_time = f"{order.delivery_date}" else: delivery_time = f"今日" diff --git a/app/core/security.py b/app/core/security.py index 53a9d24..03010b7 100644 --- a/app/core/security.py +++ b/app/core/security.py @@ -18,8 +18,6 @@ def create_access_token(data: dict, expires_delta: Optional[timedelta] = None) - to_encode.update({"exp": datetime.now(timezone.utc) + expires_delta}) else: to_encode.update({"exp": datetime.now(timezone.utc) + timedelta(days=180)}) - - print(to_encode) encoded_jwt = jwt.encode(to_encode, settings.SECRET_KEY, algorithm="HS256") return encoded_jwt @@ -30,10 +28,10 @@ def set_jwt_cookie(response: Response, token: str): key="access_token", value=token, httponly=True, # 防止JavaScript访问 - # secure=not settings.DEBUG, # 生产环境使用HTTPS - samesite="lax", # CSRF保护 - max_age=None if settings.ACCESS_TOKEN_EXPIRE_MINUTES is None - else settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60 + secure=not settings.DEBUG, # 生产环境使用HTTPS + samesite="Lax", # CSRF保护 + expires=datetime.now(timezone.utc) + timedelta(days=180), + max_age=180*24*60*60 # 30天的秒数 ) def clear_jwt_cookie(response: Response): diff --git a/requirements.txt b/requirements.txt index 4ceeca8..1f65243 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -fastapi>=0.68.0 -uvicorn>=0.15.0 +fastapi>=0.115.11 +uvicorn>=0.34.0 pydantic>=2.0.0 pydantic-settings>=2.0.0 python-jose>=3.3.0 @@ -10,8 +10,8 @@ redis==5.0.1 pymysql==1.1.0 SQLAlchemy==2.0.27 tencentcloud-sdk-python==3.0.1035 -cos-python-sdk-v5 -bcrypt +cos-python-sdk-v5==1.9.34 +bcrypt==4.3.0 aiohttp==3.9.1 cryptography==42.0.2 qrcode>=7.3.1