diff options
author | Georg | 2021-09-02 01:47:37 +0200 |
---|---|---|
committer | Georg | 2021-09-02 01:47:37 +0200 |
commit | d5f5ac7bd254ac591b4bbeb606565ac22e2ce35c (patch) | |
tree | 3796dcd10f25f5cd35cb138279c888680925f0ba | |
parent | 840265c745e668addfcd4afa741f7835cd98dca9 (diff) | |
download | webreg-d5f5ac7bd254ac591b4bbeb606565ac22e2ce35c.tar.gz webreg-d5f5ac7bd254ac591b4bbeb606565ac22e2ce35c.tar.bz2 webreg-d5f5ac7bd254ac591b4bbeb606565ac22e2ce35c.zip |
Savepointdevel_multireg
Signed-off-by: Georg <georg@lysergic.dev>
-rw-r--r-- | flaskapp.py | 28 | ||||
-rw-r--r-- | forms.py | 5 | ||||
-rw-r--r-- | irc_register.py | 1 | ||||
-rw-r--r-- | templates/register.html | 26 | ||||
-rw-r--r-- | templates/register1.html | 50 | ||||
-rw-r--r-- | templates/register2.html | 48 |
6 files changed, 141 insertions, 17 deletions
diff --git a/flaskapp.py b/flaskapp.py index c8ce2d3..440b407 100644 --- a/flaskapp.py +++ b/flaskapp.py @@ -1,5 +1,5 @@ from flask import Flask, render_template, url_for, request, redirect, flash -from forms import RegistrationForm +from forms import RegistrationForm, OptionForm from irc_register import ircregister #from irc_verify import ircverify @@ -23,13 +23,30 @@ def kiwinick(): @app.route('/register', methods=['GET', 'POST']) def register(): - form = RegistrationForm() - if request.method == 'POST': + optionform = OptionForm() + registerform = RegistrationForm() + if optionform.validate_on_submit(): + option = request.form['options'] + print(option) + print(form.option.data) + if option == 'mail-old': + return "<script>window.location.replace('/register1')</script>", 200 + #return "<script>window.location.href = '/register1'</script>", 200 + elif option == 'mail-new': + return "<script>window.location.replace('/register2')</script>", 200 + + return render_template('register.html', title='Register', optionform=optionform, registerform=registerform) +@app.route('/register1', methods=['GET', 'POST']) +def register1(): + optionform = OptionForm() + registerform = RegistrationForm() + if request.method == 'POST': username = request.form.get('username') email = request.form.get('email') password = request.form.get('password') -# email = request.form.get('email') add password arg to ircregisterfunction + option = request.form['options'] + print(option) response = ircregister(username, password, email) if response == "433": flash("IRC username already taken. Please select a different username") @@ -42,7 +59,8 @@ def register(): elif response == "ssoerr": flash("Sorry, we messed up. Please contact an administrator.") - return render_template('register.html', title='Register', form=form) + return render_template('register1.html', title='Register', optionform=optionform, registerform=registerform) + #@app.route('/verify', methods=['GET', 'POST']) #def verify(): @@ -1,7 +1,10 @@ from flask_wtf import FlaskForm -from wtforms import StringField, PasswordField, SubmitField +from wtforms import StringField, PasswordField, SubmitField, RadioField from wtforms.validators import DataRequired, Length, EqualTo, Email +class OptionForm(FlaskForm): + option = RadioField('Label', choices=[('mail-old','I want to use an existing email address.'),('mail-new','I want to create and use a new email address.')]) + submit = SubmitField('Save preference') class RegistrationForm(FlaskForm): username = StringField('Username', validators=[DataRequired(), Length(min=1, max=32)]) diff --git a/irc_register.py b/irc_register.py index 0492a86..62734a3 100644 --- a/irc_register.py +++ b/irc_register.py @@ -100,7 +100,6 @@ def ircregister(username, password, email): return "ssoerr" if status == 409: # likely already occupied username or email address print("ERROR: Keycloak indicated that the resource already exists or \"some other coonflict when processing the request\" occured.") - return "ssoerr" return "409" #to-do: parse response JSON to inform the user whether it's the username OR the email address causing the culprit if status == 415: diff --git a/templates/register.html b/templates/register.html index 9c535e3..1de1f38 100644 --- a/templates/register.html +++ b/templates/register.html @@ -26,19 +26,25 @@ └─┘ ┘ │ ──┘ ┘ │ <form method="POST" action="/register"> - {{ form.hidden_tag() }} + {{ optionform.hidden_tag() }} + {{ optionform.option }} + {{ optionform.submit }} +</form> + +<form method="POST" action="/register1"> + {{ registerform.hidden_tag() }} <fieldset> <legend>Sign Up</legend> - {{ form.username.label }} - {{ form.username }} - {{ form.email.label }} - {{ form.email }} - {{ form.password.label }} - {{ form.password }} - {{ form.confirm_password.label }} - {{ form.confirm_password }} + {{ registerform.username.label }} + {{ registerform.username }} + {{ registerform.email.label }} + {{ registerform.email }} + {{ registerform.password.label }} + {{ registerform.password }} + {{ registerform.confirm_password.label }} + {{ registerform.confirm_password }} </fieldset> - {{ form.submit }} + {{ registerform.submit }} </form> If you already have an account please login to the IRC using SASL. diff --git a/templates/register1.html b/templates/register1.html new file mode 100644 index 0000000..1de1f38 --- /dev/null +++ b/templates/register1.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<html> + +<head> + <meta charset="UTF-8"> + <title>Register</title> +<style> + body { + background-color: black; + color: white; + } +</style> +</head> + +<body> + {% for message in get_flashed_messages() %} + {{ message }} + {% endfor %} +<pre> +┬ ┌┬┐ ┬─┐ ┬─┐ ┬─┐ ┌┐┐ ┬─┐ +│ │ │─│ │─ │┬┘ │ │─┤ +┘─┘ └┴┘ │─┘ ┴─┘ │└┘ ┘ ┘ │ + +┌─┐ ┬─┐ ┐─┐ ┬─┐ +│ │─┤ └─┐ │─┤ +└─┘ ┘ │ ──┘ ┘ │ + +<form method="POST" action="/register"> + {{ optionform.hidden_tag() }} + {{ optionform.option }} + {{ optionform.submit }} +</form> + +<form method="POST" action="/register1"> + {{ registerform.hidden_tag() }} + <fieldset> + <legend>Sign Up</legend> + {{ registerform.username.label }} + {{ registerform.username }} + {{ registerform.email.label }} + {{ registerform.email }} + {{ registerform.password.label }} + {{ registerform.password }} + {{ registerform.confirm_password.label }} + {{ registerform.confirm_password }} + </fieldset> + {{ registerform.submit }} +</form> + +If you already have an account please login to the IRC using SASL. diff --git a/templates/register2.html b/templates/register2.html new file mode 100644 index 0000000..4de3760 --- /dev/null +++ b/templates/register2.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<html> + +<head> + <meta charset="UTF-8"> + <title>Register</title> +<style> + body { + background-color: black; + color: white; + } +</style> +</head> + +<body> + {% for message in get_flashed_messages() %} + {{ message }} + {% endfor %} +<pre> +┬ ┌┬┐ ┬─┐ ┬─┐ ┬─┐ ┌┐┐ ┬─┐ +│ │ │─│ │─ │┬┘ │ │─┤ +┘─┘ └┴┘ │─┘ ┴─┘ │└┘ ┘ ┘ │ + +┌─┐ ┬─┐ ┐─┐ ┬─┐ +│ │─┤ └─┐ │─┤ +└─┘ ┘ │ ──┘ ┘ │ + +<form method="POST" action="/register"> + {{ optionform.hidden_tag() }} + {{ optionform.option }} + {{ optionform.submit }} +</form> + +<form method="POST" action="/register1"> + {{ registerform.hidden_tag() }} + <fieldset> + <legend>Sign Up</legend> + {{ registerform.username.label }} + {{ registerform.username }} + {{ registerform.password.label }} + {{ registerform.password }} + {{ registerform.confirm_password.label }} + {{ registerform.confirm_password }} + </fieldset> + {{ registerform.submit }} +</form> + +If you already have an account please login to the IRC using SASL. |