From 11895bc78457daa5cdf8379b400faeab75b7a302 Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Mon, 20 Nov 2023 17:24:58 +0000 Subject: [PATCH] Updated login --- account/account.py | 24 ++++++++---------------- account/templates/err.html | 20 ++++++++++++++++++++ account/templates/wrong.html | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 account/templates/err.html create mode 100644 account/templates/wrong.html diff --git a/account/account.py b/account/account.py index d51483a..f56d16f 100644 --- a/account/account.py +++ b/account/account.py @@ -37,7 +37,7 @@ def verify_bcrypt(passphrase, hashed_password): @app.route('/') def index(): if 'passwordhash' in request.cookies and request.cookies.get('passwordhash'): - return redirect("/account/dashboard") + return render_template('dashboard.html') else: return render_template('index.html') @@ -51,14 +51,14 @@ def login(): if passwordhash: is_password_valid = verify_bcrypt(password_to_check, passwordhash) if is_password_valid: - response = make_response("Logged in!") + response = make_response(redirect('/account')) response.set_cookie('passwordhash', passwordhash) response.set_cookie('email', request.form['email']) return response else: - return "Incorrect email or password" + return render_template('wrong.html') else: - return "Email not found in the database" + return render_template('wrong.html') @app.route('/deleteapi', methods=['POST']) def delete(): @@ -74,7 +74,7 @@ def delete(): if result.returncode == 0: # Command executed successfully - response = make_response("Email deleted!") + response = make_response(redirect('/')) response.set_cookie('passwordhash', '', expires=0) response.set_cookie('email', '', expires=0) return response @@ -82,20 +82,12 @@ def delete(): # Handle errors, log them, and return False error_message = result.stderr.decode("utf-8") print(f"Error deleting email account: {error_message}") - return "Error deleting email account!" + return render_template('err.html') else: - return "Incorrect email or password" + return render_template('wrong.html') else: - return "Email not found in the database" - - -@app.route('/dashboard') -def dashboard(): - if 'passwordhash' in request.cookies and request.cookies.get('passwordhash'): - return render_template('dashboard.html') - else: - return redirect("/account") + return render_template('wrong.html') @app.route('/deleteacct') def deleteacct(): diff --git a/account/templates/err.html b/account/templates/err.html new file mode 100644 index 0000000..b3b0bc8 --- /dev/null +++ b/account/templates/err.html @@ -0,0 +1,20 @@ + + + + Error! + + + +
+ HectaMail + Sign up + Account +
+
+

Error!

+ Something went wrong on our end - the mail server could be down. Please try again later. +
+ +
+
+ diff --git a/account/templates/wrong.html b/account/templates/wrong.html new file mode 100644 index 0000000..3c3505a --- /dev/null +++ b/account/templates/wrong.html @@ -0,0 +1,20 @@ + + + + Error! + + + +
+ HectaMail + Sign up + Account +
+
+

Error!

+ Incorrect Email or password! +
+ +
+
+