Hammad712 commited on
Commit
78ac2af
·
verified ·
1 Parent(s): 8049b05

Update routes/auth_routes.py

Browse files
Files changed (1) hide show
  1. routes/auth_routes.py +6 -5
routes/auth_routes.py CHANGED
@@ -52,7 +52,7 @@ async def get_google_auth_url(redirect_to: str = None):
52
  @router.get("/callback")
53
  async def google_callback(request: Request):
54
  code = request.query_params.get("code")
55
- # We now look for 'final_dest' which we baked into the URL
56
  final_dest = request.query_params.get("final_dest")
57
 
58
  if not code:
@@ -60,13 +60,14 @@ async def google_callback(request: Request):
60
 
61
  access_token = AuthService.exchange_code(code)
62
 
63
- # If the URL contains our mobile scheme, go to the app.
64
- # Otherwise, go to Vercel.
65
  if final_dest and "digital-billboard" in final_dest:
66
- # Standard Expo redirect format
 
67
  redirect_url = f"digital-billboard://--/auth-callback#access_token={access_token}"
68
  else:
 
69
  redirect_url = f"{settings.FRONTEND_URL}/dashboard#access_token={access_token}"
70
 
71
- logger.info("AUTH_COMPLETE: Redirecting to %s", redirect_url)
72
  return RedirectResponse(url=redirect_url)
 
52
  @router.get("/callback")
53
  async def google_callback(request: Request):
54
  code = request.query_params.get("code")
55
+ # We retrieve the 'final_dest' we tucked away in the previous step
56
  final_dest = request.query_params.get("final_dest")
57
 
58
  if not code:
 
60
 
61
  access_token = AuthService.exchange_code(code)
62
 
63
+ # THE DECISION:
 
64
  if final_dest and "digital-billboard" in final_dest:
65
+ # Redirect to Mobile App
66
+ # Format: digital-billboard://--/auth-callback#access_token=...
67
  redirect_url = f"digital-billboard://--/auth-callback#access_token={access_token}"
68
  else:
69
+ # Redirect to Vercel Web
70
  redirect_url = f"{settings.FRONTEND_URL}/dashboard#access_token={access_token}"
71
 
72
+ logger.info("CALLBACK_COMPLETE: Redirecting to %s", redirect_url)
73
  return RedirectResponse(url=redirect_url)