Skip to content

Commit

Permalink
Set cookie on first redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Oct 4, 2024
1 parent 3fd88a2 commit 5009043
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions images/dashboard/src/routes/login_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ def initialize_session(request: Request, box: str = Query(...), end_redirect_uri
"created_at": new_session.created_at.isoformat(),
}
)
# Set cookie_id with session_id
response.set_cookie(key="cookie_id", value=session_id, domain="dashboard.osmsandbox.us")
logging.info("Generated new session_id and saved to database")
return response

Expand All @@ -101,7 +99,11 @@ def osm_authorization(
# Redirect to OSM auth
auth_url = f"{osm_instance_url}/oauth2/authorize?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}&scope={osm_instance_scopes}"
logging.info(f"Redirecting to auth URL: {auth_url}")
return RedirectResponse(url=auth_url, status_code=303)
response = RedirectResponse(url=auth_url, status_code=303)

# Set cookie_id with session_id
response.set_cookie(key="cookie_id", value=session_id)
return response


@router.get("/redirect_sandbox", tags=["OSM Session Sandbox"])
Expand Down Expand Up @@ -143,7 +145,7 @@ async def redirect_sandbox(request: Request, code: str, db: Session = Depends(ge

logging.info(f"Redirecting to URL: {end_redirect_uri}")
response = RedirectResponse(url=end_redirect_uri)
#response.delete_cookie("cookie_id")
response.delete_cookie("cookie_id")
return response
else:
logging.error("Session ID not found in cookies")
Expand Down

0 comments on commit 5009043

Please sign in to comment.