mirror of
https://github.com/StefBuwalda/cal_counter.git
synced 2025-10-29 19:00:00 +00:00
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:
7
app.py
7
app.py
@@ -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
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user