wu981526092 commited on
Commit
2157a09
·
1 Parent(s): 77481d0

Fix: Auth status endpoint response format and frontend cache

Browse files

🐛 Problems:
1. Frontend using old cached JavaScript (index-fe30a47e.js vs index-9bb815aa.js)
2. Backend /auth/status returns user_authenticated but frontend expects authenticated
3. Frontend expects complete user object but backend returns user_info

✅ Solutions:
Backend /auth/status endpoint:
- Added authenticated: bool(user) field for frontend compatibility
- Added user: user field containing complete user object
- Maintained legacy fields for backward compatibility

Frontend build:
- Cleared dist/ cache and rebuilt with latest session detection code
- New build should force HF Spaces to use updated JavaScript files

🔧 Technical Changes:
Backend Response Format:
- authenticated: boolean (NEW - frontend expects this)
- user: object (NEW - complete user data)
- user_authenticated: boolean (legacy)
- user_info: object (legacy)

Expected Flow:
1. Frontend loads → calls /auth/status
2. Backend returns session user if exists
3. Frontend detects authenticated: true + user data
4. AuthContext updates state → modal closes

🎯 Result:
- Proper frontend/backend auth state synchronization
- No more cached old JavaScript files
- Session-based login detection works correctly

Files changed (1) hide show
  1. backend/routers/auth.py +3 -1
backend/routers/auth.py CHANGED
@@ -40,7 +40,9 @@ async def auth_status(request: Request):
40
  "environment": "huggingface_spaces" if is_huggingface_space() else "local_development",
41
  "oauth_available": bool(config),
42
  "login_required": True, # Mandatory for OpenAI API protection
43
- "user_authenticated": bool(user),
 
 
44
  "user_info": {
45
  "auth_method": user.get("auth_method") if user else None,
46
  "username": user.get("username") if user else None,
 
40
  "environment": "huggingface_spaces" if is_huggingface_space() else "local_development",
41
  "oauth_available": bool(config),
42
  "login_required": True, # Mandatory for OpenAI API protection
43
+ "authenticated": bool(user), # Frontend expects this field
44
+ "user": user, # Frontend expects complete user object
45
+ "user_authenticated": bool(user), # Legacy field for compatibility
46
  "user_info": {
47
  "auth_method": user.get("auth_method") if user else None,
48
  "username": user.get("username") if user else None,