aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wqflask/wqflask/oauth2/routes.py34
-rw-r--r--wqflask/wqflask/templates/oauth2/register_user.html61
-rw-r--r--wqflask/wqflask/views.py1
3 files changed, 96 insertions, 0 deletions
diff --git a/wqflask/wqflask/oauth2/routes.py b/wqflask/wqflask/oauth2/routes.py
index deb540e8..83994284 100644
--- a/wqflask/wqflask/oauth2/routes.py
+++ b/wqflask/wqflask/oauth2/routes.py
@@ -1,4 +1,5 @@
"""Routes for the OAuth2 auth system in GN3"""
+import requests
from urllib.parse import urljoin
from pymonad.maybe import Just, Maybe, Nothing
@@ -72,6 +73,39 @@ def logout():
return redirect("/")
+@oauth2.route("/register-user", methods=["GET", "POST"])
+def register_user():
+ if user_logged_in():
+ next_endpoint=request.args.get("next", url_for("/"))
+ flash(("You cannot register a new user while logged in. "
+ "Please logout to register a new user."),
+ "alert-danger")
+ return redirect(next_endpoint)
+
+ if request.method == "GET":
+ return render_template("oauth2/register_user.html")
+
+ config = app.config
+ form = request.form
+ response = requests.post(
+ urljoin(config["GN_SERVER_URL"], "oauth2/register-user"),
+ data = {
+ "user_name": form.get("user_name"),
+ "email": form.get("email_address"),
+ "password": form.get("password"),
+ "confirm_password": form.get("confirm_password")})
+ results = response.json()
+ if "error" in results:
+ error_messages = tuple(
+ f"{results['error']}: {msg.strip()}"
+ for msg in results.get("error_description").split("::"))
+ for message in error_messages:
+ flash(message, "alert-danger")
+ return redirect(url_for("oauth2.register_user"))
+
+ flash("Registration successful! Please login to continue.", "alert-success")
+ return redirect(url_for("oauth2.login"))
+
@oauth2.route("/register-client", methods=["GET", "POST"])
@require_oauth2
def register_client():
diff --git a/wqflask/wqflask/templates/oauth2/register_user.html b/wqflask/wqflask/templates/oauth2/register_user.html
new file mode 100644
index 00000000..0cdcd5ff
--- /dev/null
+++ b/wqflask/wqflask/templates/oauth2/register_user.html
@@ -0,0 +1,61 @@
+{%extends "base.html"%}
+{%block title%}Register New User{%endblock%}
+{%block content%}
+<div class="container" style="min-width: 1250px;">
+ <h3>Register User</h3>
+
+ <form class="form-horizontal" action="{{url_for('oauth2.register_user')}}"
+ method="POST" id="oauth2-register-user-form">
+ <fieldset>
+ <legend>Register User</legend>
+ {{flash_me()}}
+ <div class="form-group">
+ <label class="col-xs-1 control-label" for="name"
+ style="text-align:left;">Name</label>
+ <div style="margin-left:20px;" class="col-xs-4">
+ <input id="user_name" name="user_name" type="text"
+ placeholder="Your Name" size="50"
+ class="form-control" required="required" />
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-xs-1 control-label" for="email_address"
+ style="text-align:left;">Email</label>
+ <div style="margin-left:20px;" class="col-xs-4">
+ <input id="email_address" name="email_address" type="email"
+ placeholder="your@email.address" size="50"
+ class="form-control" required="required" />
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-xs-1 control-label" for="password"
+ style="text-align:left;">Password</label>
+ <div style="margin-left:20px;" class="col-xs-4">
+ <input id="password" name="password" type="password"
+ size="50" class="form-control"
+ placeholder="your password" required="required" />
+ </div>
+ </div>
+
+ <div class="form-group">
+ <label class="col-xs-1 control-label" for="confirm_password"
+ style="text-align:left;">Confirm Password</label>
+ <div style="margin-left:20px;" class="col-xs-4">
+ <input id="confirm_password" name="confirm_password" type="password"
+ size="50" class="form-control" required="required"
+ placeholder="your password, again" />
+ </div>
+ </div>
+
+ <div class="form-group">
+ <div style="margin-left:20px;" class="col-xs-4 controls">
+ <input type="submit" class="btn btn-primary form-control" id="submit" name="submit"
+ value="Register" />
+ </div>
+ </div>
+ </fieldset>
+ </form>
+</div>
+{%endblock%}
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index a7a43a22..5f91edc8 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -874,6 +874,7 @@ def corr_compute_page():
return render_template("correlation_page.html", **output)
if jobs.completed_erroneously(job):
+ ## The "parseable" error report is actually in STDOUT
output = json.loads(job.get("stdout", "{}"))
return render_template("correlation_error_page.html", error=output)