Spaces:
Sleeping
Sleeping
fix(auth): accept refresh_token from JSON body to resolve 422 on refresh endpoint
Browse files- docs/hflogs/runtimeerror.txt +61 -57
- src/app/api/v1/auth.py +3 -3
- src/app/schemas/auth.py +5 -0
docs/hflogs/runtimeerror.txt
CHANGED
|
@@ -1,62 +1,66 @@
|
|
| 1 |
-
===== Application Startup at 2025-11-
|
| 2 |
|
| 3 |
INFO: Started server process [7]
|
| 4 |
INFO: Waiting for application startup.
|
| 5 |
-
INFO: 2025-11-
|
| 6 |
-
INFO: 2025-11-
|
| 7 |
-
INFO: 2025-11-
|
| 8 |
-
INFO: 2025-11-
|
| 9 |
-
INFO: 2025-11-
|
| 10 |
-
INFO: 2025-11-
|
| 11 |
-
INFO: 2025-11-
|
| 12 |
-
INFO: 2025-11-
|
| 13 |
-
INFO: 2025-11-
|
| 14 |
-
INFO: 2025-11-
|
| 15 |
-
INFO: 2025-11-
|
| 16 |
-
INFO: 2025-11-
|
| 17 |
-
INFO: 2025-11-
|
| 18 |
-
INFO: 2025-11-
|
| 19 |
-
INFO: 2025-11-
|
| 20 |
-
INFO: 2025-11-
|
| 21 |
INFO: Application startup complete.
|
| 22 |
INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
|
| 23 |
-
INFO: 10.16.
|
| 24 |
-
INFO: 10.16.
|
| 25 |
-
INFO: 10.16.
|
| 26 |
-
INFO: 10.16.
|
| 27 |
-
INFO: 10.16.
|
| 28 |
-
INFO: 10.16.
|
| 29 |
-
INFO: 10.16.42.67:
|
| 30 |
-
INFO: 10.16.25.6:
|
| 31 |
-
INFO: 10.16.
|
| 32 |
-
INFO: 10.16.42.67:
|
| 33 |
-
INFO: 10.16.44.
|
| 34 |
-
INFO: 10.16.
|
| 35 |
-
INFO: 10.16.
|
| 36 |
-
INFO: 10.16.
|
| 37 |
-
INFO: 10.16.
|
| 38 |
-
INFO: 10.16.
|
| 39 |
-
INFO: 10.16.
|
| 40 |
-
INFO: 10.16.
|
| 41 |
-
INFO: 10.16.
|
| 42 |
-
INFO: 10.16.42.67:
|
| 43 |
-
INFO: 10.16.
|
| 44 |
-
INFO: 10.16.25.6:
|
| 45 |
-
INFO: 10.16.
|
| 46 |
-
INFO: 10.16.
|
| 47 |
-
INFO: 10.16.44.
|
| 48 |
-
INFO: 10.16.
|
| 49 |
-
INFO: 10.16.
|
| 50 |
-
INFO: 10.16.
|
| 51 |
-
INFO: 10.16.
|
| 52 |
-
INFO: 10.16.44.
|
| 53 |
-
INFO: 10.16.42.67:
|
| 54 |
-
INFO: 10.16.
|
| 55 |
-
INFO: 10.16.44.
|
| 56 |
-
INFO: 10.16.
|
| 57 |
-
INFO: 10.16.
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
INFO: 10.16.
|
| 61 |
-
INFO: 10.16.
|
| 62 |
-
INFO: 10.16.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===== Application Startup at 2025-11-18 08:59:49 =====
|
| 2 |
|
| 3 |
INFO: Started server process [7]
|
| 4 |
INFO: Waiting for application startup.
|
| 5 |
+
INFO: 2025-11-18T09:00:04 - app.main: ============================================================
|
| 6 |
+
INFO: 2025-11-18T09:00:04 - app.main: π SwiftOps API v1.0.0 | PRODUCTION
|
| 7 |
+
INFO: 2025-11-18T09:00:04 - app.main: ============================================================
|
| 8 |
+
INFO: 2025-11-18T09:00:04 - app.main: π¦ Database:
|
| 9 |
+
INFO: 2025-11-18T09:00:08 - app.main: β Connected | 42 tables | 13 users
|
| 10 |
+
INFO: 2025-11-18T09:00:08 - app.main: πΎ Cache & Sessions:
|
| 11 |
+
INFO: 2025-11-18T09:00:09 - app.services.otp_service: β
OTP Service initialized with Redis storage
|
| 12 |
+
INFO: 2025-11-18T09:00:09 - app.main: β Redis: Connected
|
| 13 |
+
INFO: 2025-11-18T09:00:09 - app.main: π External Services:
|
| 14 |
+
INFO: 2025-11-18T09:00:11 - app.main: β Cloudinary: Connected
|
| 15 |
+
INFO: 2025-11-18T09:00:11 - app.main: β Resend: Configured
|
| 16 |
+
INFO: 2025-11-18T09:00:11 - app.main: β WASender: Connected
|
| 17 |
+
INFO: 2025-11-18T09:00:11 - app.main: β Supabase: Connected | 6 buckets
|
| 18 |
+
INFO: 2025-11-18T09:00:11 - app.main: ============================================================
|
| 19 |
+
INFO: 2025-11-18T09:00:11 - app.main: β
Startup complete | Ready to serve requests
|
| 20 |
+
INFO: 2025-11-18T09:00:11 - app.main: ============================================================
|
| 21 |
INFO: Application startup complete.
|
| 22 |
INFO: Uvicorn running on http://0.0.0.0:7860 (Press CTRL+C to quit)
|
| 23 |
+
INFO: 10.16.12.18:26269 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 24 |
+
INFO: 10.16.44.154:44924 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 25 |
+
INFO: 10.16.12.18:26269 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 26 |
+
INFO: 10.16.12.18:22464 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 27 |
+
INFO: 10.16.25.6:1259 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 28 |
+
INFO: 10.16.2.183:9110 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 29 |
+
INFO: 10.16.42.67:46793 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 30 |
+
INFO: 10.16.25.6:8359 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 31 |
+
INFO: 10.16.2.183:3578 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 32 |
+
INFO: 10.16.42.67:45252 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 33 |
+
INFO: 10.16.44.154:42469 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 34 |
+
INFO: 10.16.44.154:42469 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 35 |
+
INFO: 10.16.2.183:3194 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 36 |
+
INFO: 10.16.2.183:33060 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 37 |
+
INFO: 10.16.25.6:30917 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 38 |
+
INFO: 10.16.44.154:38800 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 39 |
+
INFO: 10.16.12.18:45701 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 40 |
+
INFO: 10.16.2.183:10285 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 41 |
+
INFO: 10.16.2.183:49419 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 42 |
+
INFO: 10.16.42.67:28250 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 43 |
+
INFO: 10.16.12.18:5003 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 44 |
+
INFO: 10.16.25.6:36117 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 45 |
+
INFO: 10.16.12.18:5003 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 46 |
+
INFO: 10.16.42.67:53582 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 47 |
+
INFO: 10.16.44.154:40677 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 48 |
+
INFO: 10.16.42.67:31017 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 49 |
+
INFO: 10.16.25.6:5467 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 50 |
+
INFO: 10.16.44.154:25386 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 51 |
+
INFO: 10.16.42.67:28837 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 52 |
+
INFO: 10.16.44.154:65418 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 53 |
+
INFO: 10.16.42.67:6962 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 54 |
+
INFO: 10.16.25.6:17800 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 55 |
+
INFO: 10.16.44.154:56179 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 56 |
+
INFO: 10.16.44.154:27040 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 57 |
+
INFO: 10.16.2.183:30209 - "GET /api/v1/health HTTP/1.1" 404 Not Found
|
| 58 |
+
INFO: 10.16.42.67:26656 - "GET /api/v1/auth/me HTTP/1.1" 200 OK
|
| 59 |
+
INFO: 10.16.44.154:60538 - "GET /api/v1/clients?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 60 |
+
INFO: 10.16.42.67:22719 - "GET /api/v1/users?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 61 |
+
INFO: 10.16.45.138:47190 - "GET /api/v1/contractors?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 62 |
+
INFO: 10.16.45.138:21893 - "POST /api/v1/auth/refresh-token HTTP/1.1" 422 Unprocessable Entity
|
| 63 |
+
INFO: 10.16.45.138:47190 - "GET /api/v1/audit-logs?skip=0&limit=100 HTTP/1.1" 200 OK
|
| 64 |
+
INFO: 10.16.25.6:49664 - "GET /health HTTP/1.1" 200 OK
|
| 65 |
+
INFO: 10.16.42.67:1809 - "GET / HTTP/1.1" 200 OK
|
| 66 |
+
INFO: 10.16.12.18:8736 - "GET / HTTP/1.1" 200 OK
|
src/app/api/v1/auth.py
CHANGED
|
@@ -7,7 +7,7 @@ from app.api.deps import get_db, get_current_active_user
|
|
| 7 |
from app.core.rate_limit import limiter
|
| 8 |
from app.schemas.auth import (
|
| 9 |
LoginRequest, TokenResponse, PasswordChange,
|
| 10 |
-
ForgotPasswordRequest, ResetPasswordRequest, MessageResponse
|
| 11 |
)
|
| 12 |
from app.schemas.user import (
|
| 13 |
UserCreate, UserResponse, UserUpdate, UserProfile,
|
|
@@ -445,7 +445,7 @@ async def login(request: Request, response: Response, credentials: LoginRequest,
|
|
| 445 |
|
| 446 |
@router.post("/refresh-token", response_model=TokenResponse)
|
| 447 |
async def refresh_access_token(
|
| 448 |
-
|
| 449 |
db: Session = Depends(get_db)
|
| 450 |
):
|
| 451 |
"""
|
|
@@ -477,7 +477,7 @@ async def refresh_access_token(
|
|
| 477 |
"""
|
| 478 |
try:
|
| 479 |
# Refresh session with Supabase
|
| 480 |
-
auth_response = await supabase_auth.refresh_session(refresh_token)
|
| 481 |
|
| 482 |
if not auth_response or not auth_response.get("session"):
|
| 483 |
raise HTTPException(
|
|
|
|
| 7 |
from app.core.rate_limit import limiter
|
| 8 |
from app.schemas.auth import (
|
| 9 |
LoginRequest, TokenResponse, PasswordChange,
|
| 10 |
+
RefreshTokenRequest, ForgotPasswordRequest, ResetPasswordRequest, MessageResponse
|
| 11 |
)
|
| 12 |
from app.schemas.user import (
|
| 13 |
UserCreate, UserResponse, UserUpdate, UserProfile,
|
|
|
|
| 445 |
|
| 446 |
@router.post("/refresh-token", response_model=TokenResponse)
|
| 447 |
async def refresh_access_token(
|
| 448 |
+
request_data: RefreshTokenRequest,
|
| 449 |
db: Session = Depends(get_db)
|
| 450 |
):
|
| 451 |
"""
|
|
|
|
| 477 |
"""
|
| 478 |
try:
|
| 479 |
# Refresh session with Supabase
|
| 480 |
+
auth_response = await supabase_auth.refresh_session(request_data.refresh_token)
|
| 481 |
|
| 482 |
if not auth_response or not auth_response.get("session"):
|
| 483 |
raise HTTPException(
|
src/app/schemas/auth.py
CHANGED
|
@@ -37,6 +37,11 @@ class PasswordChange(BaseModel):
|
|
| 37 |
return v
|
| 38 |
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
class ForgotPasswordRequest(BaseModel):
|
| 41 |
"""Schema for forgot password request"""
|
| 42 |
email: EmailStr
|
|
|
|
| 37 |
return v
|
| 38 |
|
| 39 |
|
| 40 |
+
class RefreshTokenRequest(BaseModel):
|
| 41 |
+
"""Schema for refresh token request"""
|
| 42 |
+
refresh_token: str = Field(..., min_length=1)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
class ForgotPasswordRequest(BaseModel):
|
| 46 |
"""Schema for forgot password request"""
|
| 47 |
email: EmailStr
|