dismissal local storage web browser

This commit is contained in:
ChrispyBacon-dev 2025-08-07 11:34:54 +02:00
parent 91673c2ea6
commit 5672e8e8fc
3 changed files with 17 additions and 12 deletions

View file

@ -657,6 +657,21 @@ document.querySelectorAll('.tunnel-dns-toggle').forEach(button => {
startServerPing();
const securityWarning = document.getElementById('security-warning');
if (securityWarning) {
if (localStorage.getItem('security_warning_dismissed') !== 'true') {
securityWarning.style.display = 'flex';
}
const dismissButton = document.getElementById('dismiss-security-warning');
if (dismissButton) {
dismissButton.addEventListener('click', function() {
securityWarning.style.display = 'none';
localStorage.setItem('security_warning_dismissed', 'true');
});
}
}
// Universal Cleanup
window.addEventListener('beforeunload', function() {
if (activeLogSource) activeLogSource.close();

View file

@ -71,20 +71,15 @@
<main class="mx-auto px-4 sm:px-6 lg:px-8 py-8 sm:py-12 flex-grow w-full max-w-screen-2xl">
{% if not (config.DOCKFLARE_PASSWORD and config.SECRET_KEY) %}
{% if not session.get('security_warning_dismissed') %}
<div id="security-warning" class="alert alert-error shadow-lg mb-8">
<div id="security-warning" class="alert alert-error shadow-lg mb-8" style="display: none;">
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>
<div>
<h3 class="font-bold">Security Warning!</h3>
<div class="text-xs">Your DockFlare instance is not password protected. Please set the `DOCKFLARE_PASSWORD` and `SECRET_KEY` environment variables to secure your instance.</div>
<a href="https://github.com/ChrispyBacon-dev/DockFlare/releases" target="_blank" rel="noopener noreferrer" class="link link-hover text-info">View Release Notes for instructions.</a>
</div>
<form action="{{ url_for('web.dismiss_security_warning') }}" method="POST">
{% if config.DOCKFLARE_PASSWORD and config.SECRET_KEY %}<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>{% endif %}
<button type="submit" class="btn btn-sm">Okay</button>
</form>
<button id="dismiss-security-warning" class="btn btn-sm">Okay</button>
</div>
{% endif %}
{% endif %}
{% block content %}{% endblock %}
</main>

View file

@ -92,11 +92,6 @@ def logout():
logout_user()
return redirect(url_for('web.login'))
@bp.route('/dismiss-security-warning', methods=['POST'])
def dismiss_security_warning():
session['security_warning_dismissed'] = True
return redirect(request.referrer or url_for('web.status_page'))
def get_display_token_ui(token_value):
if not token_value: return "Not available"
return f"{token_value[:5]}...{token_value[-5:]}" if len(token_value) > 10 else "Token (short)"