From 6b62a1f89bd01e4393bbfd414f35b675b3734cc5 Mon Sep 17 00:00:00 2001 From: Gregoo Date: Sat, 18 Jan 2025 21:02:43 +0100 Subject: [PATCH] Do not show the login page if already logged in --- bricktracker/views/login.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bricktracker/views/login.py b/bricktracker/views/login.py index 8b56315..18556b5 100644 --- a/bricktracker/views/login.py +++ b/bricktracker/views/login.py @@ -3,6 +3,7 @@ import logging from flask import ( Blueprint, current_app, + g, redirect, render_template, request, @@ -27,7 +28,11 @@ login_page = Blueprint('login', __name__) # Index @login_page.route('/login', methods=['GET']) @exception_handler(__file__) -def login() -> str: +def login() -> str | Response: + # Do not log if logged in + if g.login.is_authenticated(): + return redirect(url_for('index.index')) + return render_template( 'login.html', next=request.args.get('next'),