aboutsummaryrefslogtreecommitdiff
path: root/jb/views
diff options
context:
space:
mode:
authorstuppie2026-09-29 14:55:44 -0600
committerstuppie2026-09-29 14:55:44 -0600
commit814782db6d829c20279cde00cdc1a7a5ef18b74a (patch)
tree403a76095ca3c1f7f6971dff3245319930df5af3 /jb/views
parent5d26a04de9ae188edc45e77d213202b1ce921be9 (diff)
downloadamt-jb-master.tar.gz
amt-jb-master.zip
If the email already has transitioned, treat this as a login requestHEADmaster
Diffstat (limited to 'jb/views')
-rw-r--r--jb/views/auth.py20
-rw-r--r--jb/views/wallet.py6
2 files changed, 16 insertions, 10 deletions
diff --git a/jb/views/auth.py b/jb/views/auth.py
index ba1a6f8..e6410a6 100644
--- a/jb/views/auth.py
+++ b/jb/views/auth.py
@@ -86,8 +86,10 @@ def authenticate_invite_amt_account_link(
@auth_router.post("/magic-link/request/")
def request_magic_link(body: AccountLogin) -> dict[str, str]:
- """Create a magic link."""
- email = str(body.email)
+ return _request_magic_link(str(body.email))
+
+
+def _request_magic_link(email: str) -> dict[str, str]:
token = create_magic_token(user_email=email)
if settings.debug:
@@ -181,15 +183,19 @@ def _exchange_magic_link(
@auth_router.post("/link-amt/request/")
-def link_amt_account(body: AmtAccountLink) -> dict[str, str]:
+def link_amt_account(
+ body: AmtAccountLink,
+ gr_api: Annotated[GRApiManager, Depends(get_gr_api_manager)],
+) -> dict[str, str]:
"""Link an AMT account and login."""
email = str(body.email)
amt_worker_id = body.amt_worker_id
- # TODO! Prevent a user that's already transitioned their account, from being
- # TODO! able to continuously create this special link token.
- # TODO! Max Notes: this seems to be handled within the gr-api, and that
- # TODO! can raise, the following line would / should fail if needed.
+ # If the email already has transitioned, treat this as a login request
+ user = User.model_validate({"email": email})
+ user_exists = gr_api.get_user_if_exists(user.product_user_id)
+ if user_exists:
+ return _request_magic_link(email)
token = create_amt_account_link_token(email=email, amt_worker_id=amt_worker_id)
diff --git a/jb/views/wallet.py b/jb/views/wallet.py
index 681cc21..de295ac 100644
--- a/jb/views/wallet.py
+++ b/jb/views/wallet.py
@@ -5,7 +5,7 @@ from urllib.parse import urlencode
from fastapi import APIRouter, Depends, HTTPException, status
from fastapi.responses import HTMLResponse
from generalresearch.models.thl.definitions import PayoutStatus
-from generalresearch.models.thl.wallet.cashout_method import CashoutRequestInfo
+from generalresearch.models.thl.wallet.cashout_method import CashoutRequestDetail
from generalresearch.redis_helper import RedisConfig
from jb.api.auth import get_authenticated_user
@@ -77,11 +77,11 @@ def cashout_confirmation_page() -> HTMLResponse:
)
-@wallet_router.post("/cashout/confirm/", response_model=CashoutRequestInfo)
+@wallet_router.post("/cashout/confirm/", response_model=CashoutRequestDetail)
def confirm_cashout(
body: CashoutConfirmation,
user: Annotated[User, Depends(get_authenticated_user)],
-) -> CashoutRequestInfo:
+) -> CashoutRequestDetail:
cashout = consume_cashout_token(body.token)
return user_cashout_request(