bozo-backend/login.py

18 lines
647 B
Python
Raw Permalink Normal View History

2023-06-03 10:58:57 -04:00
import flask
2023-06-08 16:32:56 -04:00
import database
2023-06-03 10:58:57 -04:00
page = flask.Blueprint("login", __name__, template_folder="templates")
2023-06-04 06:51:13 -04:00
@page.route("/login", methods=['POST', 'GET'])
2023-06-04 06:51:13 -04:00
def show():
2023-06-09 09:22:50 -04:00
if (flask.session.get("email")):
return (flask.redirect("/panel"))
2023-06-08 16:32:56 -04:00
if (flask.request.method == 'GET'):
2023-06-03 10:58:57 -04:00
return (flask.render_template("login/login.html"))
2023-06-08 16:32:56 -04:00
email = flask.request.form['email']
password = flask.request.form['password']
if (database.database.account_test(email, password)):
return (flask.render_template("login/login.html", error = "Invalid credentials"))
2023-06-09 09:22:50 -04:00
flask.session["email"] = email;
2023-06-08 16:32:56 -04:00
return (flask.redirect("/panel"))