Read flask session type from environment variable and create sessions table if not exist.

This commit is contained in:
Rauno Tuul 2023-03-08 17:05:32 +02:00
parent 68d9fb3755
commit aa70951964
2 changed files with 9 additions and 3 deletions

View File

@ -93,7 +93,6 @@ legal_envvars_bool = (
'SIGNUP_ENABLED',
'LOCAL_DB_ENABLED',
'LDAP_ENABLED',
'SESSION_TYPE',
'SESSION_COOKIE_SECURE',
'CSRF_COOKIE_SECURE',
'CAPTCHA_ENABLE',

View File

@ -56,8 +56,15 @@ def create_app(config=None):
_sslify = SSLify(app) # lgtm [py/unused-local-variable]
# Load Flask-Session
sess = Session()
sess.init_app(app)
app.config['SESSION_TYPE'] = app.config.get('SESSION_TYPE')
if 'SESSION_TYPE' in os.environ:
app.config['SESSION_TYPE'] = os.environ.get('SESSION_TYPE')
sess = Session(app)
# create sessions table if using sqlalchemy backend
if os.environ.get('SESSION_TYPE') == 'sqlalchemy':
sess.app.session_interface.db.create_all()
# SMTP
app.mail = Mail(app)