feat(apk): generateur de mot de passe, erreurs du depot affichees dans les reglages

- de sur le champ mot de passe (nouvelle entree et modification), tirage
  crypto.getRandomValues avec rejet
- Download vault sans reglages ouvre les reglages
- 404/401 tranches (jeton refuse, utilisateur ou depot inexistant, fichier
  absent) et mauvais mot de passe de synchro : les reglages s'ouvrent avec
  le message en rouge

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-09-18 10:18:47 +01:00
parent 3eb26e23e5
commit ba8c4205f9
3 changed files with 132 additions and 7 deletions
+33 -5
View File
@@ -352,6 +352,7 @@ type
/// que le proprietaire ne connaitrait pas.
procedure SetUnlockCode(const ANew: string);
procedure PushUnlockMode;
procedure ShowSettingsError(const AMsg: string);
// Scanner du QR affiche par le poste (ZXing.Delphi, Apache 2.0).
var
FScanning, FScanBusy: Boolean;
@@ -2526,9 +2527,15 @@ begin
// range qui ne convient plus.
LPwd := FPwd;
if LPwd = '' then LPwd := FSyncPwd;
if (LUrl = '') or (LTok = '') then
begin
ShowSettingsError('Set the repository first - scan the QR shown on the PC,'
+ ' or type the URL and the token');
Exit;
end;
if LPwd = '' then
begin
StatusErr('Sync password required');
ShowSettingsError('Sync password required');
Exit;
end;
WebCall('PM.clearLog()');
@@ -2745,8 +2752,15 @@ begin
// Le serveur repond pareil dans les deux cas, par conception.
Log(' 404: no snapshot OR invalid token');
if not ASilent then
TThread.Queue(nil, procedure
begin Status('Nothing to download (404)'); end);
begin
// TRANCHER L'AMBIGUITE : fichier absent, depot ou utilisateur
// inexistant - deux requetes de plus, seulement quand
// quelqu'un attend la reponse.
var LWhy := LClient.Diagnose(404);
if LWhy = '' then LWhy := 'Nothing to download (404)';
Log(' ' + LWhy);
TThread.Queue(nil, procedure begin ShowSettingsError(LWhy); end);
end;
Exit;
end;
ssRefused, ssHttpError, ssNetworkError:
@@ -2755,7 +2769,12 @@ begin
// est affiche, hors ligne est un etat normal, et une alerte ici
// apprendrait a l'utilisateur a ignorer les alertes.
Log(' failed: ' + LRes.Error);
if not ASilent then
if (not ASilent) and (LRes.HttpCode = 401) then
begin
var LWhy401 := LClient.Diagnose(401);
TThread.Queue(nil, procedure begin ShowSettingsError(LWhy401); end);
end
else if not ASilent then
TThread.Queue(nil, procedure
begin StatusErr('Network failure'); end);
Exit;
@@ -2881,7 +2900,7 @@ begin
// le champ prerempli, et le coffre local reste consultable.
if not ASilent then
TThread.Queue(nil, procedure
begin Status('Failed - wrong sync password?'); end);
begin ShowSettingsError('Wrong sync password - it must be the one set on the PC'); end);
end;
end;
finally
@@ -3620,6 +3639,15 @@ begin
WebCall('PM.setStatus(' + JsArg(AMsg) + ', true)');
end;
/// UNE ERREUR DE REGLAGE S'AFFICHE LA OU ON LA CORRIGE : les reglages s'ouvrent
/// et le message y est en rouge, au-dessus des champs du depot.
procedure TForm8.ShowSettingsError(const AMsg: string);
begin
StatusErr(AMsg);
WebCall('openSettings()');
WebCall('PM.settingsError(' + JsArg(AMsg) + ')');
end;
procedure TForm8.SetBusy(ABusy: Boolean);
var
LCanOpen: Boolean;