From ac67c674ccc3b329eeee9aa2dcd38c1a506c8034 Mon Sep 17 00:00:00 2001 From: Reditus <33814724+ReditusDraco@users.noreply.github.com> Date: Mon, 15 Jun 2026 12:26:46 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20backup=20password=20UX=20=E2=80=94=20mas?= =?UTF-8?q?ked=20modals,=20validation,=20schedule=20password=20never=20sen?= =?UTF-8?q?t=20to=20client?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/api.py | 4 +- app/services/backup.py | 10 +++-- templates/backup.html | 90 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 94 insertions(+), 10 deletions(-) diff --git a/app/routes/api.py b/app/routes/api.py index 3e49655..b9b47ea 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -2146,7 +2146,9 @@ def register_api_routes(app, services, settings): @app.route('/api/backup/schedule', methods=['GET']) @auth_req def api_backup_schedule_get(): - return jsonify({'success': True, 'schedule': backup_svc.get_schedule()}) + sched = backup_svc.get_schedule() + sched.pop('password', None) # never send password to client + return jsonify({'success': True, 'schedule': sched}) @app.route('/api/backup/schedule', methods=['POST']) @auth_req diff --git a/app/services/backup.py b/app/services/backup.py index db4bdf2..42a503d 100644 --- a/app/services/backup.py +++ b/app/services/backup.py @@ -12,7 +12,7 @@ import threading import time from datetime import datetime, timedelta -from cryptography.fernet import Fernet +from cryptography.fernet import Fernet, InvalidToken from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC @@ -311,7 +311,9 @@ class BackupService: cfg['schedule_times'] = data['schedule_times'] cfg['keep'] = int(data.get('keep', cfg['keep'])) if 'password' in data: - cfg['password'] = data['password'] + if data['password']: + cfg['password'] = data['password'] + # empty string = keep existing password (don't overwrite) if cfg.get('mode') == 'schedule': cfg['next_run'] = self._next_run_from_schedule(cfg) else: @@ -434,8 +436,10 @@ class BackupService: 'size': os.path.getsize(path), 'components': meta.get('components', []), } + except InvalidToken: + return {'success': False, 'valid': False, 'error': 'Wrong password'} except Exception as e: - return {'success': False, 'valid': False, 'error': str(e)} + return {'success': False, 'valid': False, 'error': f'Backup corrupted: {e}'} # ── Restore Orchestration ───────────────────────────────────────── diff --git a/templates/backup.html b/templates/backup.html index 64ca3e2..4a1f031 100644 --- a/templates/backup.html +++ b/templates/backup.html @@ -119,7 +119,7 @@
-
@@ -264,8 +264,51 @@ } + + + + + +