2023-06-05 12:47:29 -04:00
|
|
|
import flask
|
2023-06-08 10:32:44 -04:00
|
|
|
import User
|
|
|
|
import database
|
2023-06-05 12:47:29 -04:00
|
|
|
|
|
|
|
page = flask.Blueprint("register", __name__, template_folder="templates")
|
|
|
|
|
2023-06-08 10:32:44 -04:00
|
|
|
@page.route("/register", methods = ['POST', 'GET'])
|
2023-06-05 12:47:29 -04:00
|
|
|
def show():
|
2023-06-08 10:32:44 -04:00
|
|
|
if (flask.request.method == 'GET'):
|
|
|
|
return (flask.render_template("register/register.html", error = None))
|
|
|
|
email = flask.request.form.get("email");
|
|
|
|
password = flask.request.form.get("password");
|
|
|
|
first_name = flask.request.form.get("firstname");
|
|
|
|
last_name = flask.request.form.get("lastname");
|
|
|
|
username = flask.request.form.get("pseudo");
|
|
|
|
if (email == None or password == None or first_name == None or last_name == None or username == None):
|
|
|
|
return (flask.render_template("register/register.html", error = "internal error"))
|
|
|
|
user = User.User(first_name, last_name, username, password, email, {});
|
|
|
|
error = database.database.add_user(user)
|
|
|
|
if (error != None):
|
|
|
|
return (flask.render_template("register/register.html", error = error))
|
|
|
|
return (flask.redirect("/panel"))
|
|
|
|
|