summaryrefslogtreecommitdiffstats
path: root/flaskapp.py
diff options
context:
space:
mode:
authorGeorg2021-09-01 12:55:44 +0200
committerGeorg2021-09-01 12:55:44 +0200
commitd2e8fcd2b5949c7836feaf559cd65c5062a7748c (patch)
treea46305087626f5362e4719f255f296e77056b010 /flaskapp.py
downloadwebreg-d2e8fcd2b5949c7836feaf559cd65c5062a7748c.tar.gz
webreg-d2e8fcd2b5949c7836feaf559cd65c5062a7748c.tar.bz2
webreg-d2e8fcd2b5949c7836feaf559cd65c5062a7748c.zip
Init + SSO registration
Signed-off-by: Georg <georg@lysergic.dev>
Diffstat (limited to 'flaskapp.py')
-rw-r--r--flaskapp.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/flaskapp.py b/flaskapp.py
new file mode 100644
index 0000000..cfa21e8
--- /dev/null
+++ b/flaskapp.py
@@ -0,0 +1,64 @@
+from flask import Flask, render_template, url_for, request, redirect, flash
+from forms import RegistrationForm
+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')
+
+@app.route('/kiwi')
+def kiwi():
+ return redirect("https://liberta.casa/kiwi/")
+@app.route('/kiwi/')
+def kiwinick(nick, show_password_box):
+ nick = request.args.get('nick', None)
+ show_password_box = requests.args.get('show_password_box', None)
+ return redirect("https://liberta.casa/kiwi/")
+
+@app.route('/register', methods=['GET', 'POST'])
+def register():
+ form = 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
+ response = ircregister(username, password, email)
+ if response == "server failure":
+ flash("Server Unavailable")
+ elif response == "433":
+ flash("Username already taken. Please select a different username")
+ elif response == "success":
+ return redirect(url_for('kiwinick', nick=username, show_password_box='true'))
+ elif response == "failure":
+ flash("Failure! Please try after some time or use NickServ.")
+
+ return render_template('register.html', title='Register', form=form)
+
+#@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)