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 @@