Move logout route to auth blueprint

The logout route was relocated from the main app to the auth blueprint for better organization. The logout link in the base template was updated to reference the new route location.
This commit is contained in:
2025-08-11 18:05:30 +02:00
parent 97ff4acf02
commit c7395b07d9
3 changed files with 11 additions and 9 deletions

7
app.py
View File

@@ -55,13 +55,6 @@ def favicon():
return send_from_directory("static", "favicon.ico")
@app.route("/logout")
@login_required
def logout():
logout_user()
return redirect(url_for("index"))
# Run
if __name__ == "__main__":
# If there are no users, create admin account

View File

@@ -1,5 +1,5 @@
from flask import Blueprint, request, render_template, redirect, url_for
from flask_login import current_user, login_user
from flask_login import current_user, login_user, logout_user
from forms import LoginForm, ChangePasswordForm
from models import User
from application.utils import default_return
@@ -48,3 +48,12 @@ def change_password():
db.session.commit()
return default_return()
return render_template("change_password.html", form=form)
@bp.route("/logout")
def logout():
if not current_user.is_authenticated:
return redirect(url_for("auth.login"))
logout_user()
return redirect(url_for("index"))

View File

@@ -32,7 +32,7 @@
<ul class="navbar-nav">
{% if current_user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for('logout') }}">Logout</a>
<a class="nav-link" href="{{ url_for('auth.logout') }}">Logout</a>
</li>
{% else %}
<li class="nav-item">