From ae872ee69bf8e81a2ee11e68b178e4470a902ae5 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Sat, 18 Mar 2023 09:11:10 +0300 Subject: oauth2: resources: Disallow duplicate resource names. --- wqflask/wqflask/oauth2/resources.py | 12 ++++++++---- wqflask/wqflask/templates/oauth2/create-resource.html | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/oauth2/resources.py b/wqflask/wqflask/oauth2/resources.py index 8f31f7c9..aacde369 100644 --- a/wqflask/wqflask/oauth2/resources.py +++ b/wqflask/wqflask/oauth2/resources.py @@ -27,7 +27,9 @@ def create_resource(): return render_template( "oauth2/create-resource.html", resource_categories=categories, - resource_category_error=error) + resource_category_error=error, + resource_name=request.args.get("resource_name"), + resource_category=request.args.get("resource_category")) if request.method == "GET": return oauth2_get("oauth2/resource/categories").either( @@ -38,9 +40,11 @@ def create_resource(): from flask import jsonify def __perr__(error): err = process_error(error) - print(f"THE ERROR: {err}") - flash(f"{err['error']}: {err['error_message']}", "alert-danger") - return redirect(url_for("oauth2.resource.user_resources")) + flash(f"{err['error']}: {err['error_description']}", "alert-danger") + return redirect(url_for( + "oauth2.resource.create_resource", + resource_name=request.form.get("resource_name"), + resource_category=request.form.get("resource_category"))) def __psuc__(succ): flash("Resource created successfully", "alert-success") return redirect(url_for("oauth2.resource.user_resources")) diff --git a/wqflask/wqflask/templates/oauth2/create-resource.html b/wqflask/wqflask/templates/oauth2/create-resource.html index 9d9a8cd3..1b4263ed 100644 --- a/wqflask/wqflask/templates/oauth2/create-resource.html +++ b/wqflask/wqflask/templates/oauth2/create-resource.html @@ -28,6 +28,9 @@
The resource name, e.g. the experiment name. @@ -38,10 +41,17 @@
{%for category in resource_categories%}
- -- cgit v1.2.3