From 9853214d8309ad16df830e2fb3bdfecbfce5653f Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 25 Aug 2023 16:47:22 +1000 Subject: [PATCH] main: Add failed login page --- master/main.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/master/main.py b/master/main.py index ad3a760..e3b4243 100644 --- a/master/main.py +++ b/master/main.py @@ -462,18 +462,25 @@ def admin(): @app.route('/login', methods=['POST']) def login(): - if request.method == 'POST': - # Handle login - print('Login attempt', flush=True) - password = request.form['password'] - if os.getenv('ADMIN_KEY') == password: - # Generate login key - login_key = os.urandom(32).hex() - logins.append(login_key) - # Set cookie - resp = make_response(redirect('/admin')) - resp.set_cookie('login_key', login_key) - return resp + # Handle login + print('Login attempt', flush=True) + password = request.form['password'] + print('Password: ' + password, flush=True) + if os.getenv('ADMIN_KEY') == password: + print('Login success', flush=True) + # Generate login key + login_key = os.urandom(32).hex() + logins.append(login_key) + # Set cookie + resp = make_response(redirect('/admin')) + resp.set_cookie('login_key', login_key) + return resp + print('Login failed', flush=True) + return redirect('/failed-login') + +@app.route('/failed-login') +def failed_login(): + return "

Failed login


"