Refactor login flow to use auth blueprint

Moved login route and logic from app.py to application/auth/routes.py under the 'auth' blueprint. Updated all references to the login route to use 'auth.login'. Added a dedicated login.html template under application/auth/templates. Adjusted login_required utility and default_return logic for consistency.
This commit is contained in:
2025-08-11 17:43:46 +02:00
parent ea2ea27d9e
commit 0da580faf1
6 changed files with 74 additions and 34 deletions

View File

@@ -1,11 +1,21 @@
from flask_login import current_user
from flask import redirect, url_for, flash
from typing import Optional
def login_required():
if not current_user.is_authenticated:
return redirect(url_for("auth.login"))
if current_user.must_change_password:
# if current_user.must_change_password:
flash("You have to change your password")
return redirect(url_for("auth.change_password"))
return
def default_return(next_page: Optional[str] = None):
return redirect(url_for("user.daily_log"))
if next_page:
return redirect(next_page)
if current_user.is_admin:
return redirect(url_for("admin.food_items"))
return redirect(url_for("dashboard"))