2021-09-01 12:55:44 +02:00
|
|
|
from flask import Flask, render_template, url_for, request, redirect, flash
|
2021-09-02 01:47:37 +02:00
|
|
|
from forms import RegistrationForm, OptionForm
|
2021-09-01 12:55:44 +02:00
|
|
|
from irc_register import ircregister
|
|
|
|
#from irc_verify import ircverify
|
|
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
app.config['SECRET_KEY'] = '$secret' #remove later
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def hello():
|
|
|
|
return render_template('home.html')
|
|
|
|
|
2021-09-01 16:36:05 +02:00
|
|
|
#@app.route('/kiwi')
|
|
|
|
#def kiwi():
|
|
|
|
# return redirect("https://liberta.casa/kiwi/")
|
2021-09-01 12:55:44 +02:00
|
|
|
@app.route('/kiwi')
|
2021-09-01 16:36:05 +02:00
|
|
|
def kiwinick():
|
2021-09-01 12:55:44 +02:00
|
|
|
nick = request.args.get('nick', None)
|
2021-09-01 16:36:05 +02:00
|
|
|
show_password_box = request.args.get('show_password_box', None)
|
|
|
|
redirect_url = 'https://liberta.casa/kiwi/'+'?nick='+nick+'&show_password_box'+'='+show_password_box
|
|
|
|
return redirect(redirect_url)
|
2021-09-01 12:55:44 +02:00
|
|
|
|
|
|
|
@app.route('/register', methods=['GET', 'POST'])
|
|
|
|
def register():
|
2021-09-02 01:47:37 +02:00
|
|
|
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)
|
2021-09-01 12:55:44 +02:00
|
|
|
|
2021-09-02 01:47:37 +02:00
|
|
|
@app.route('/register1', methods=['GET', 'POST'])
|
|
|
|
def register1():
|
|
|
|
optionform = OptionForm()
|
|
|
|
registerform = RegistrationForm()
|
|
|
|
if request.method == 'POST':
|
2021-09-01 12:55:44 +02:00
|
|
|
username = request.form.get('username')
|
|
|
|
email = request.form.get('email')
|
|
|
|
password = request.form.get('password')
|
2021-09-02 01:47:37 +02:00
|
|
|
option = request.form['options']
|
|
|
|
print(option)
|
2021-09-01 12:55:44 +02:00
|
|
|
response = ircregister(username, password, email)
|
2021-09-01 16:36:05 +02:00
|
|
|
if response == "433":
|
|
|
|
flash("IRC username already taken. Please select a different username")
|
|
|
|
elif response == "409":
|
|
|
|
flash("User already exists.")
|
2021-09-01 12:55:44 +02:00
|
|
|
elif response == "success":
|
|
|
|
return redirect(url_for('kiwinick', nick=username, show_password_box='true'))
|
2021-09-01 16:36:05 +02:00
|
|
|
elif response == "invalidemail":
|
|
|
|
flash("Is that a valid email address?")
|
|
|
|
elif response == "ssoerr":
|
|
|
|
flash("Sorry, we messed up. Please contact an administrator.")
|
2021-09-01 12:55:44 +02:00
|
|
|
|
2021-09-02 01:47:37 +02:00
|
|
|
return render_template('register1.html', title='Register', optionform=optionform, registerform=registerform)
|
|
|
|
|
2021-09-01 12:55:44 +02:00
|
|
|
|
|
|
|
#@app.route('/verify', methods=['GET', 'POST'])
|
|
|
|
#def verify():
|
|
|
|
# form = VerificationForm()
|
|
|
|
# if request.method == 'POST':
|
|
|
|
#
|
|
|
|
# username = request.form.get('username')
|
|
|
|
# verif_code = request.form.get('verif_code')
|
|
|
|
# response = ircverify(username, verif_code)
|
|
|
|
# if response == "server failure":
|
|
|
|
# flash("Server Unavailable")
|
|
|
|
# elif response == "433":
|
|
|
|
# flash("Username under use. Please check your username or visit us for help")
|
|
|
|
# elif response == "success":
|
|
|
|
# return redirect(url_for('kiwi'))
|
|
|
|
# elif response == "failure":
|
|
|
|
# flash("Failure! Please try after some time or use NickServ.")
|
|
|
|
# return render_template('verify.html', title='Verify', form=form)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app.run(debug=True)
|