diff options
author | Frederick Muriuki Muriithi | 2023-01-30 18:07:30 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-01-30 18:07:30 +0300 |
commit | f783e93bd80a75b1a9f0ea115e4136c4c4fbd092 (patch) | |
tree | b3ea062bd548fab8db7c217249dcbd225f57b078 /wqflask | |
parent | 4074daae55618f0e1df283cfdd14bc63a7360781 (diff) | |
download | genenetwork2-f783e93bd80a75b1a9f0ea115e4136c4c4fbd092.tar.gz |
oauth2: Fix missing imports and update URLs
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/oauth2/groups.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/oauth2/toplevel.py | 12 | ||||
-rw-r--r-- | wqflask/wqflask/templates/oauth2/login.html | 4 | ||||
-rw-r--r-- | 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 @@ <form class="form-horizontal" {%if next_endpoint%} - action="{{url_for('oauth2.login', next=next_endpoint)}}" + action="{{url_for('oauth2.toplevel.login', next=next_endpoint)}}" {%else%} - action="{{url_for('oauth2.login')}}" + action="{{url_for('oauth2.toplevel.login')}}" {%endif%} method="POST" id="oauth2-login-form"> <fieldset> 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 @@ <div class="container" style="min-width: 1250px;"> <h3>Register User</h3> - <form class="form-horizontal" action="{{url_for('oauth2.register_user')}}" + <form class="form-horizontal" + action="{{url_for('oauth2.toplevel.register_user')}}" method="POST" id="oauth2-register-user-form"> <fieldset> <legend>Register User</legend> |