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
|
|
|
|
2023-06-05 12:47:29 -04:00
|
|
|
page = flask.Blueprint("login", __name__, template_folder="templates")
|
2023-06-04 06:51:13 -04:00
|
|
|
|
2023-06-05 12:47:29 -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"))
|