redirect to login when session expires

This commit is contained in:
Karl Hudgell 2024-11-11 12:36:02 +00:00
parent 24435e57b0
commit 554359d7f5

26
app.py
View File

@ -41,18 +41,20 @@ def index():
@app.route("/home") @app.route("/home")
@cache.cached(timeout=60) # cache for 120 seconds @cache.cached(timeout=60) # cache for 120 seconds
def home(): def home():
base_url = app.config["BASE_URL"] # Access base_url from the config if session.get("logged_in"):
all_accounts = get_user_accounts(base_url, session["auth_credentials"]) base_url = app.config["BASE_URL"] # Access base_url from the config
count = len(all_accounts) all_accounts = get_user_accounts(base_url, session["auth_credentials"])
current_month_accounts = filter_accounts_current_month(all_accounts) count = len(all_accounts)
expired_accounts = filter_accounts_expired(all_accounts) current_month_accounts = filter_accounts_current_month(all_accounts)
return render_template( expired_accounts = filter_accounts_expired(all_accounts)
"home.html", return render_template(
username=session["username"], "home.html",
accounts=count, username=session["username"],
current_month_accounts=current_month_accounts, accounts=count,
expired_accounts=expired_accounts, current_month_accounts=current_month_accounts,
) expired_accounts=expired_accounts,
)
return render_template("index.html")
@app.route("/login", methods=["POST"]) @app.route("/login", methods=["POST"])