aboutsummaryrefslogtreecommitdiff
path: root/jb/views
diff options
context:
space:
mode:
Diffstat (limited to 'jb/views')
-rw-r--r--jb/views/auth.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/jb/views/auth.py b/jb/views/auth.py
index 06dbdde..33c9452 100644
--- a/jb/views/auth.py
+++ b/jb/views/auth.py
@@ -18,12 +18,12 @@ from jb.api.auth import (
)
from jb.api.magic_token import consume_magic_token, create_magic_token
from jb.config import settings
-from jb.decorators import gr_api_manager
+from jb.dependencies import get_gr_api_manager
+from jb.managers.gr_api import GRApiManager
from jb.models.auth import (
- MagicLinkExchangeRequest,
AccountLogin,
+ MagicLinkExchangeRequest,
User,
- email_to_product_user_id,
)
from jb.settings import BASE_HTML
@@ -58,13 +58,17 @@ def magic_link_landing_page() -> HTMLResponse:
@auth_router.post("/magic-link/exchange", status_code=status.HTTP_204_NO_CONTENT)
-def exchange_magic_link(body: MagicLinkExchangeRequest, response: Response) -> None:
+def exchange_magic_link(
+ body: MagicLinkExchangeRequest,
+ response: Response,
+ gr_api: Annotated[GRApiManager, Depends(get_gr_api_manager)],
+) -> None:
"""Exchange a magic link only after its landing page makes an explicit POST."""
user_email = consume_magic_token(body.token)
- user = User.model_validate({'email': user_email})
+ user = User.model_validate({"email": user_email})
# hit thl to make sure this user exists
- user = gr_api_manager.ensure_user_exists(user)
+ user = gr_api.ensure_user_exists(user)
session_token = create_session(user.product_user_id)
response.set_cookie(