fix: backup password UX — masked modals, validation, schedule password never sent to client

This commit is contained in:
Reditus committed 2026-06-15 12:26:46 +01:00
1 parent 306ebcc871
commit a2d5af20c9
3 files changed
+94 -10

No files matched your search

+3 -1
View File
@@ -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
+7 -3
View File
@@ -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 ─────────────────────────────────────────