From 5811e0e8788790a84ade3ca0826b716686ac07b9 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Wed, 5 Oct 2022 11:15:56 +0300 Subject: [PATCH] token path param --- auth/email.py | 3 +-- main.py | 2 +- resolvers/auth.py | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/auth/email.py b/auth/email.py index cde0f03e..f99dcb64 100644 --- a/auth/email.py +++ b/auth/email.py @@ -11,9 +11,8 @@ async def send_auth_email(user, token): Follow the link to authorize """ - url = "%s/confirm-email" % BACKEND_URL to = "%s <%s>" % (user.username, user.email) - url_with_token = "%s?token=%s" % (url, token) + url_with_token = "%s/confirm-email/%s" % (BACKEND_URL, token) text = text % url_with_token response = requests.post( MAILGUN_API_URL, diff --git a/main.py b/main.py index cf17ff8f..22172bcf 100644 --- a/main.py +++ b/main.py @@ -55,7 +55,7 @@ async def shutdown(): routes = [ Route("/oauth/{provider}", endpoint=oauth_login), Route("/oauth_authorize", endpoint=oauth_authorize), - Route("/confirm-email", endpoint=confirm_email_handler), # should be called on client + Route("/confirm-email/{token}", endpoint=confirm_email_handler), # should be called on client ] app = Starlette( diff --git a/resolvers/auth.py b/resolvers/auth.py index 8956cb05..eabd6479 100644 --- a/resolvers/auth.py +++ b/resolvers/auth.py @@ -59,7 +59,6 @@ async def confirm_email(_, _info, confirm_token): async def confirm_email_handler(request): - print(request) token = request.path_params["token"] # one time request.session["token"] = token res = await confirm_email(None, token)