From 9cf2da1128825bcd41eecc0f5bc1a7ed31dc9bd2 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Thu, 3 Apr 2025 17:00:45 +0200 Subject: [PATCH] Update routes --- src/anonchat/admin_routes.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/anonchat/admin_routes.py b/src/anonchat/admin_routes.py index ec16e15..e228247 100644 --- a/src/anonchat/admin_routes.py +++ b/src/anonchat/admin_routes.py @@ -17,10 +17,19 @@ def admin_required(f): return decorated_function @app.route('/admin', methods=['GET']) -def admin_login(): - return render_template('admin_login.html') +def admin(): + if is_admin(): + return redirect(url_for('admin_dashboard')) + return redirect(url_for('admin_login')) -@app.route('/admin', methods=['POST']) +@app.route('/admin/login', methods=['GET']) +def admin_login_get(): + next_page = request.args.get('next') or url_for('admin_dashboard') + if is_admin(): + return redirect(next_page) + return render_template('admin_login.html', next=next_page) + +@app.route('/admin/login', methods=['POST']) @limiter.limit("1 per minute", deduct_when=lambda response: not is_admin()) @limiter.limit("10 per hour") def admin_login_post():