Added a session_timeout setting to manage session lifetime

This commit is contained in:
Olivier DUMAS 2018-10-01 19:15:09 +02:00
parent 9a4eebfd42
commit 4cd422ee54
2 changed files with 7 additions and 0 deletions

View File

@ -1808,6 +1808,7 @@ class Setting(db.Model):
'allow_user_create_domain': False,
'bg_domain_updates': False,
'site_name': 'PowerDNS-Admin',
'session_timeout': 10,
'pdns_api_url': '',
'pdns_api_key': '',
'pdns_version': '4.1.1',

View File

@ -3,6 +3,7 @@ import logging as logger
import os
import traceback
import re
import datetime
from distutils.util import strtobool
from distutils.version import StrictVersion
from functools import wraps
@ -68,6 +69,11 @@ def before_request():
if maintenance and current_user.is_authenticated and current_user.role.name not in ['Administrator', 'Operator']:
return render_template('maintenance.html')
# Manage session timeout
session.permanent = True
app.permanent_session_lifetime = datetime.timedelta(minutes=int(Setting().get('session_timeout')))
session.modified = True
g.user = current_user
@login_manager.user_loader
def load_user(id):