aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-08-20 15:22:03 -0500
committerFrederick Muriuki Muriithi2024-08-20 16:03:51 -0500
commit41d5835414082fc6e21f2d668ffd07a34afcf6ec (patch)
treee8fec13631945713e98280c276d50c0eb4b92234 /gn_auth/auth
parentc16eb0722657e7804aeb930749d4c2cc2cc89aff (diff)
downloadgn-auth-41d5835414082fc6e21f2d668ffd07a34afcf6ec.tar.gz
Pass GET parameters for correct redirection.
Diffstat (limited to 'gn_auth/auth')
-rw-r--r--gn_auth/auth/authorisation/users/views.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/gn_auth/auth/authorisation/users/views.py b/gn_auth/auth/authorisation/users/views.py
index 3083724..3323f4d 100644
--- a/gn_auth/auth/authorisation/users/views.py
+++ b/gn_auth/auth/authorisation/users/views.py
@@ -1,4 +1,5 @@
"""User authorisation endpoints."""
+import uuid
import sqlite3
import secrets
import traceback
@@ -368,7 +369,13 @@ def send_verification_code():
return resp
-def send_forgot_password_email(conn, user: User):
+def send_forgot_password_email(
+ conn,
+ user: User,
+ client_id: uuid.UUID,
+ redirect_uri: str,
+ response_type: str
+):
"""Send the 'forgot-password' email."""
subject="GeneNetwork: Change Your Password"
token = secrets.token_urlsafe(64)
@@ -380,7 +387,10 @@ def send_forgot_password_email(conn, user: User):
forgot_password_uri=urljoin(
request.url,
url_for("oauth2.users.change_password",
- forgot_password_token=token)),
+ forgot_password_token=token,
+ client_id=client_id,
+ redirect_uri=redirect_uri,
+ response_type=response_type)),
expiration_minutes=expiration_minutes)
with db.cursor(conn) as cursor:
@@ -413,7 +423,10 @@ def send_forgot_password_email(conn, user: User):
def forgot_password():
"""Enable user to request password change."""
if request.method == "GET":
- return render_template("users/forgot-password.html")
+ return render_template("users/forgot-password.html",
+ client_id=request.args["client_id"],
+ redirect_uri=request.args["redirect_uri"],
+ response_type=request.args["response_type"])
form = request.form
email = form.get("email", "").strip()
@@ -429,7 +442,11 @@ def forgot_password():
"alert-danger")
return redirect(url_for("oauth2.users.forgot_password"))
- send_forgot_password_email(conn, user)
+ send_forgot_password_email(conn,
+ user,
+ request.args["client_id"],
+ request.args["redirect_uri"],
+ request.args["response_type"])
return render_template("users/forgot-password-token-send-success.html")