mirror of
https://github.com/mynodebtc/mynode.git
synced 2024-11-15 01:49:15 +00:00
Add function for controlling session timeout
This commit is contained in:
parent
be3a7f0d60
commit
aef0e015d1
|
@ -8,6 +8,7 @@ from lightning_info import is_lnd_ready, get_lnd_status, get_lnd_status_color
|
|||
from systemctl_info import *
|
||||
from electrum_info import get_electrs_status, is_electrs_active
|
||||
from bitcoin_info import get_bitcoin_status, is_bitcoind_synced
|
||||
from datetime import timedelta
|
||||
import time
|
||||
import json
|
||||
import os
|
||||
|
@ -713,6 +714,20 @@ def get_flask_secret_key():
|
|||
set_file_contents("/home/bitcoin/.mynode/flask_secret_key", key)
|
||||
return key
|
||||
|
||||
def get_flask_session_timeout():
|
||||
try:
|
||||
if os.path.isfile("/home/bitcoin/.mynode/flask_session_timeout"):
|
||||
timeout = get_file_contents("/home/bitcoin/.mynode/flask_session_timeout")
|
||||
parts = timeout.split(",")
|
||||
d = parts[0]
|
||||
h = parts[1]
|
||||
return timedelta(days=d, hours=h)
|
||||
else:
|
||||
set_file_contents("/home/bitcoin/.mynode/flask_session_timeout", "90,0")
|
||||
return timedelta(days=90, hours=0)
|
||||
except:
|
||||
return timedelta(days=90, hours=0)
|
||||
|
||||
|
||||
#==================================
|
||||
# Uploader Functions
|
||||
|
|
|
@ -61,7 +61,7 @@ app.config['MAX_CONTENT_LENGTH'] = 32 * 1024 * 1024 # 32 MB upload file max
|
|||
app.config['UPLOAD_FOLDER'] = "/tmp/flask_uploads"
|
||||
app.config["SESSION_COOKIE_NAME"] = "mynode_session_id"
|
||||
app.secret_key = get_flask_secret_key()
|
||||
app.permanent_session_lifetime = timedelta(days=90)
|
||||
app.permanent_session_lifetime = get_flask_session_timeout()
|
||||
app.register_error_handler(LoginError, handle_login_exception)
|
||||
|
||||
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||
|
|
Loading…
Reference in New Issue
Block a user