Add option to set auto-logout time period
This commit is contained in:
parent
fcaf1c5ee8
commit
d9cf512474
|
@ -721,12 +721,23 @@ def get_flask_session_timeout():
|
|||
parts = timeout.split(",")
|
||||
d = parts[0]
|
||||
h = parts[1]
|
||||
return timedelta(days=d, hours=h)
|
||||
return int(d),int(h)
|
||||
else:
|
||||
set_file_contents("/home/bitcoin/.mynode/flask_session_timeout", "90,0")
|
||||
return timedelta(days=90, hours=0)
|
||||
return 90,0
|
||||
except:
|
||||
return timedelta(days=90, hours=0)
|
||||
return 90,0
|
||||
|
||||
def set_flask_session_timeout(days, hours):
|
||||
set_file_contents("/home/bitcoin/.mynode/flask_session_timeout", "{},{}".format(days, hours))
|
||||
os.system("sync")
|
||||
|
||||
|
||||
#==================================
|
||||
# Uploader Functions
|
||||
#==================================
|
||||
def restart_flask():
|
||||
os.system("systemctl restart www")
|
||||
|
||||
|
||||
#==================================
|
||||
|
|
|
@ -61,7 +61,8 @@ 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 = get_flask_session_timeout()
|
||||
timeout_days, timeout_hours = get_flask_session_timeout()
|
||||
app.permanent_session_lifetime = timedelta(days=timeout_days, hours=timeout_hours)
|
||||
app.register_error_handler(LoginError, handle_login_exception)
|
||||
|
||||
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||
|
|
|
@ -49,6 +49,7 @@ def page_settings():
|
|||
upload_rate = 100
|
||||
download_rate = 100
|
||||
|
||||
logout_time_days, logout_time_hours = get_flask_session_timeout()
|
||||
|
||||
templateData = {
|
||||
"title": "myNode Settings",
|
||||
|
@ -69,6 +70,8 @@ def page_settings():
|
|||
"product_key_error": pk_error,
|
||||
"changelog": changelog,
|
||||
"is_https_forced": is_https_forced(),
|
||||
"logout_time_days": logout_time_days,
|
||||
"logout_time_hours": logout_time_hours,
|
||||
"using_bitcoin_custom_config": using_bitcoin_custom_config(),
|
||||
"using_lnd_custom_config": using_lnd_custom_config(),
|
||||
"is_bitcoin_synced": is_bitcoind_synced(),
|
||||
|
@ -615,6 +618,29 @@ def change_quicksync_rates_page():
|
|||
return redirect(url_for(".page_settings"))
|
||||
|
||||
|
||||
@mynode_settings.route("/settings/logout_time", methods=['POST'])
|
||||
def change_logout_time_page():
|
||||
check_logged_in()
|
||||
if not request:
|
||||
return redirect("/settings")
|
||||
|
||||
d = request.form.get('logout_days')
|
||||
h = request.form.get('logout_hours')
|
||||
|
||||
if d == "0" and h == "0":
|
||||
flash("Logout time cannot be 0 hours and 0 days", category="error")
|
||||
return redirect(url_for(".page_settings"))
|
||||
|
||||
set_flask_session_timeout(d, h)
|
||||
|
||||
# Trigger reboot
|
||||
t = Timer(3.0, restart_flask)
|
||||
t.start()
|
||||
|
||||
flash("Automatic logout time updated!", category="message")
|
||||
return redirect(url_for(".page_settings"))
|
||||
|
||||
|
||||
@mynode_settings.route("/settings/delete-lnd-wallet", methods=['POST'])
|
||||
def page_lnd_delete_wallet():
|
||||
check_logged_in()
|
||||
|
|
|
@ -535,6 +535,30 @@
|
|||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">Automatic Logout</div>
|
||||
Your myNode will logout automatically after a period of time. It can be changed below.
|
||||
<br/><br/>
|
||||
|
||||
<form action="/settings/logout_time" method="POST">
|
||||
{% set logoutDays = [0,1,2,3,5,7,10,15,20,30,60,90] %}
|
||||
{% set logoutHours = range(24) %}
|
||||
Days:
|
||||
<select name="logout_days" id="logout_days">
|
||||
{% for d in logoutDays %}
|
||||
<option value="{{d}}" {% if logout_time_days == d %}selected{% endif %}>{{d}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
Hours:
|
||||
<select name="logout_hours" id="logout_hours">
|
||||
{% for h in logoutHours %}
|
||||
<option value="{{h}}" {% if logout_time_hours == h %}selected{% endif %}>{{h}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" id="logout_save_button" value="Save" class="ui-button ui-widget ui-corner-all settings_button_small"/>
|
||||
</form>
|
||||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">Force HTTPS</div>
|
||||
You can force the myNode web interface to only use HTTPS.
|
||||
<br/><br/>
|
||||
|
|
Loading…
Reference in New Issue
Block a user