Savepoint
Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
parent
840265c745
commit
d5f5ac7bd2
28
flaskapp.py
28
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():
|
||||
|
5
forms.py
5
forms.py
@ -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)])
|
||||
|
@ -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:
|
||||
|
@ -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.
|
||||
|
50
templates/register1.html
Normal file
50
templates/register1.html
Normal file
@ -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.
|
48
templates/register2.html
Normal file
48
templates/register2.html
Normal file
@ -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.
|
Loading…
Reference in New Issue
Block a user