From 03bbb4df4e7a6a6b0bbccfabe8a28b380d12bd80 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 17 Jun 2024 10:57:17 -0500 Subject: Use the form's json attribute to retrieve sent data The system uses JSON as the default communication format, so we use the form's json attribute to get any data sent. --- gn_auth/auth/authorisation/users/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gn_auth/auth/authorisation/users') diff --git a/gn_auth/auth/authorisation/users/views.py b/gn_auth/auth/authorisation/users/views.py index 1d3b128..cc70d76 100644 --- a/gn_auth/auth/authorisation/users/views.py +++ b/gn_auth/auth/authorisation/users/views.py @@ -166,7 +166,7 @@ def register_user() -> Response: __assert_not_logged_in__(conn) try: - form = request.form + form = request.json email = validate_email(form.get("email", "").strip(), check_deliverability=True) password = validate_password( @@ -204,7 +204,7 @@ def delete_verification_code(cursor, code: str): @users.route("/verify", methods=["GET", "POST"]) def verify_user(): """Verify users are not bots.""" - form = request.form + form = request.json loginuri = redirect(url_for( "oauth2.auth.authorise", response_type=(request.args.get("response_type") @@ -308,7 +308,7 @@ def list_all_users() -> Response: @users.route("/handle-unverified", methods=["POST"]) def handle_unverified(): """Handle case where user tries to login but is unverified""" - form = request.form + form = request.json # TODO: Maybe have a GN2_URI setting here? # or pass the client_id here? return render_template( @@ -321,7 +321,7 @@ def handle_unverified(): @users.route("/send-verification", methods=["POST"]) def send_verification_code(): """Send verification code email.""" - form = request.form + form = request.json with (db.connection(current_app.config["AUTH_DB"]) as conn, db.cursor(conn) as cursor): user = user_by_email(conn, form["user_email"]) -- cgit v1.2.3