Update main.py
Browse files
main.py
CHANGED
@@ -59,14 +59,14 @@ async def login_post(
|
|
59 |
)
|
60 |
|
61 |
# Redirect the user to the protected route with the token in the URL
|
62 |
-
|
63 |
-
return RedirectResponse(url=f"/protected?token={access_token}")
|
64 |
#return RedirectResponse(f"{url}?token={access_token}")
|
65 |
|
66 |
-
|
67 |
-
|
68 |
# response.set_cookie(key="access_token", value=access_token, httponly=True)
|
69 |
-
|
70 |
elif user and not user.is_verified: # User is not verified
|
71 |
raise HTTPException(
|
72 |
status_code=400,
|
|
|
59 |
)
|
60 |
|
61 |
# Redirect the user to the protected route with the token in the URL
|
62 |
+
url = app.url_path_for("get_protected") # Ensure you have a name="get_protected" in your app.get("/protected") decorator
|
63 |
+
#return RedirectResponse(url=f"/protected?token={access_token}", status_code=status.HTTP_303_SEE_OTHER)
|
64 |
#return RedirectResponse(f"{url}?token={access_token}")
|
65 |
|
66 |
+
response = RedirectResponse(f"{url}?token={access_token}", status_code=status.HTTP_303_SEE_OTHER)
|
67 |
+
response.set_cookie(key="access_token", value=f"Bearer {access_token}", httponly=True)
|
68 |
# response.set_cookie(key="access_token", value=access_token, httponly=True)
|
69 |
+
return response
|
70 |
elif user and not user.is_verified: # User is not verified
|
71 |
raise HTTPException(
|
72 |
status_code=400,
|