Add MAX_AGE config parameter

This commit is contained in:
augustin64 2024-01-13 12:44:28 +01:00
parent acaa8367d6
commit d54419fd35
2 changed files with 10 additions and 0 deletions

View File

@ -16,3 +16,6 @@ DISABLE_REGISTER=False
# Front URL of the application (for QRCodes generation)
BASE_URL="http://localhost:5000"
# Session expiration, in days
MAX_AGE=31

View File

@ -3,6 +3,7 @@
Main file
"""
import os
import datetime
import subprocess
from flask import Flask, g, redirect, render_template, request, send_file, flash, session, abort
@ -105,6 +106,12 @@ def search_thumbnail(uuid):
return send_file(os.path.join(app.static_folder, "search-thumbnails", f"{uuid}.jpg"))
@app.before_request
def before_request():
"""Set cookie max age to 31 days"""
session.permanent = True
app.permanent_session_lifetime = datetime.timedelta(days=int(app.config["MAX_AGE"]))
@app.context_processor
def inject_default_variables():
"""Inject the version number in the template variables"""