Compare commits
1 Commits
master
...
devel_mult
Author | SHA1 | Date | |
---|---|---|---|
d5f5ac7bd2 |
13
LICENSE
13
LICENSE
@ -1,13 +0,0 @@
|
||||
Copyright (c) 2021-2022 Pratyush Desai and others
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
Neither the name of the author of this software nor the name of contributors to this software may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Portions of the included source code are copyright by its original author(s) and remain subject to its associated license.
|
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)])
|
||||
|
@ -7,17 +7,16 @@ def ircregister(username, password, email):
|
||||
d = irctokens.StatefulDecoder()
|
||||
e = irctokens.StatefulEncoder()
|
||||
s = socket.socket()
|
||||
securesocket = ssl.create_default_context().wrap_socket(s, server_hostname="irc.casa")
|
||||
|
||||
#connecting to the server
|
||||
securesocket.connect(("theia.psyched.dev", 6697))
|
||||
s.connect(("127.0.0.1", 6667))
|
||||
|
||||
#defining the send function with proper formatting
|
||||
def _send(line):
|
||||
print(f"> {line.format()}")
|
||||
e.push(line)
|
||||
while e.pending():
|
||||
e.pop(securesocket.send(e.pending()))
|
||||
e.pop(s.send(e.pending()))
|
||||
|
||||
# registering the connection to the server
|
||||
_send(irctokens.build("USER", [username, "0", "*", username]))
|
||||
@ -34,7 +33,7 @@ def ircregister(username, password, email):
|
||||
|
||||
# go through the cases
|
||||
while True:
|
||||
lines = d.push(securesocket.recv(1024))
|
||||
lines = d.push(s.recv(1024))
|
||||
|
||||
if lines == None: # if nothing is received from server
|
||||
return "server error"
|
||||
@ -101,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…
x
Reference in New Issue
Block a user