From f783e93bd80a75b1a9f0ea115e4136c4c4fbd092 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 30 Jan 2023 18:07:30 +0300 Subject: oauth2: Fix missing imports and update URLs --- wqflask/wqflask/oauth2/groups.py | 2 +- wqflask/wqflask/oauth2/toplevel.py | 12 +++++++++--- wqflask/wqflask/templates/oauth2/login.html | 4 ++-- wqflask/wqflask/templates/oauth2/register_user.html | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/wqflask/wqflask/oauth2/groups.py b/wqflask/wqflask/oauth2/groups.py index d04509df..d2102404 100644 --- a/wqflask/wqflask/oauth2/groups.py +++ b/wqflask/wqflask/oauth2/groups.py @@ -29,7 +29,7 @@ def create_group(): @groups.route("/join-or-create", methods=["GET"]) @require_oauth2 -def group_join_or_create(): +def join_or_create(): user_details = __user_details__() if bool(user_details["group"]): flash("You are already a member of a group.", "alert info.") diff --git a/wqflask/wqflask/oauth2/toplevel.py b/wqflask/wqflask/oauth2/toplevel.py index b002c4c2..a998909c 100644 --- a/wqflask/wqflask/oauth2/toplevel.py +++ b/wqflask/wqflask/oauth2/toplevel.py @@ -1,6 +1,11 @@ """Authentication endpoints.""" +import requests +from urllib.parse import urljoin -from flask import Blueprint +from authlib.integrations.base_client.errors import OAuthError +from flask import ( + flash, request, session, Blueprint, url_for, redirect, render_template, + current_app as app) from .client import oauth2_client from .checks import require_oauth2, user_logged_in @@ -15,6 +20,7 @@ def login(): if request.method == "POST": form = request.form client = oauth2_client() + config = app.config try: token = client.fetch_token( urljoin(config["GN_SERVER_URL"], "oauth2/token"), @@ -79,10 +85,10 @@ def register_user(): for msg in results.get("error_description").split("::")) for message in error_messages: flash(message, "alert-danger") - return redirect(url_for("oauth2.register_user")) + return redirect(url_for("oauth2.toplevel.register_user")) flash("Registration successful! Please login to continue.", "alert-success") - return redirect(url_for("oauth2.login")) + return redirect(url_for("oauth2.toplevel.login")) @toplevel.route("/register-client", methods=["GET", "POST"]) @require_oauth2 diff --git a/wqflask/wqflask/templates/oauth2/login.html b/wqflask/wqflask/templates/oauth2/login.html index 3de15812..d3e0a4d8 100644 --- a/wqflask/wqflask/templates/oauth2/login.html +++ b/wqflask/wqflask/templates/oauth2/login.html @@ -6,9 +6,9 @@
diff --git a/wqflask/wqflask/templates/oauth2/register_user.html b/wqflask/wqflask/templates/oauth2/register_user.html index 0cdcd5ff..65d28548 100644 --- a/wqflask/wqflask/templates/oauth2/register_user.html +++ b/wqflask/wqflask/templates/oauth2/register_user.html @@ -4,7 +4,8 @@

Register User

-
Register User -- cgit v1.2.3