diff --git a/android-client/web/app.html b/android-client/web/app.html index 044ae7a..15b8791 100644 --- a/android-client/web/app.html +++ b/android-client/web/app.html @@ -1622,7 +1622,7 @@ document.addEventListener('click', function (ev) { // LES REGLAGES. Ils lisent et ecrivent les MEMES champs que l'accueil - la // page n'en garde qu'une copie, Delphi reste la seule source. function openSettings() { - document.getElementById('sUrl').value = elUrl.value; + document.getElementById('sUrl').value = shortRepoUrl(elUrl.value); document.getElementById('sTok').value = elTok.value; document.getElementById('sPwd').value = elPwd.value; document.getElementById('sPinNew').value = ''; @@ -1639,6 +1639,13 @@ function openSettings() { // https://git.example.com/OWNER/REPO (ou .../src/branch/main/FICHIER) devient // l'URL de l'API des contenus. Une URL d'API ou d'endpoint PHP passe telle quelle, // et une forme non reconnue aussi - Sync dira alors ce qui ne va pas. +// L'inverse, pour l'affichage : l'URL d'API se relit comme l'adresse du depot. +function shortRepoUrl(u) { + var m = /^(https?:\/\/[^\/]+)\/api\/v1\/repos\/([^\/]+)\/([^\/]+)\/contents\/(.+)$/i.exec(u || ''); + if (!m) return u; + return m[1] + '/' + m[2] + '/' + m[3] + + (m[4] === 'vault-sync.json' ? '' : '/src/branch/main/' + m[4]); +} function normalizeRepoUrl(u) { u = u.replace(/\s+/g, ''); if (!u || /\/api\/v1\/repos\//i.test(u) || /\.php(\?|$)/i.test(u)) return u; @@ -1648,8 +1655,8 @@ function normalizeRepoUrl(u) { } document.getElementById('sSave').addEventListener('click', function () { var sUrl = document.getElementById('sUrl'); - sUrl.value = normalizeRepoUrl(sUrl.value); - elUrl.value = sUrl.value; + elUrl.value = normalizeRepoUrl(sUrl.value); + sUrl.value = shortRepoUrl(elUrl.value); elTok.value = document.getElementById('sTok').value.trim(); elPwd.value = document.getElementById('sPwd').value; pushConfig(); @@ -1687,6 +1694,9 @@ document.getElementById('sLog').addEventListener('click', function () { // verrouillage d'ecran, c'est retirer le code : il faut donc le code courant. var unlockMode = 'none', canDeviceLock = false, hasContainer = false; function syncUnlockUi() { + var pw = hasContainer ? 'vault password' : 'sync password'; + document.getElementById('sModePwd').dataset.label = + pw.charAt(0).toUpperCase() + pw.slice(1) + ' (type it above)'; ['device', 'code', 'password'].forEach(function (m) { var id = { device: 'sModeDevice', code: 'sModeCode', password: 'sModePwd' }[m]; var b = document.getElementById(id), on = unlockMode === m; @@ -1698,7 +1708,7 @@ function syncUnlockUi() { document.getElementById('sModeNote').textContent = { device: 'Now: screen lock. Changing the screen lock or adding a fingerprint never deletes the vault.', code: 'Now: app code. To go back to the screen lock, type the current code above.', - password: 'Now: vault password. To go back to the screen lock, type it above.', + password: 'Now: ' + pw + '. To go back to the screen lock, type it above.', none: 'Now: no protection - anyone holding the phone unlocked can open the vault.' }[unlockMode] + (canDeviceLock ? '' : ' This phone has no screen lock.'); document.getElementById('btnUsePwd').hidden = @@ -1716,7 +1726,7 @@ document.getElementById('sModeCode').addEventListener('click', function () { }); document.getElementById('sModePwd').addEventListener('click', function () { var v = modeField(); - if (!v) { toast('Type the vault password above first'); return; } + if (!v) { toast('Type the ' + (hasContainer ? 'vault' : 'sync') + ' password above first'); return; } send('pinset?pw=1&c=' + encodeURIComponent(v)); }); document.getElementById('sModeDevice').addEventListener('click', function () { diff --git a/mainApk.pas b/mainApk.pas index 588a66b..c4ca5bc 100644 --- a/mainApk.pas +++ b/mainApk.pas @@ -341,6 +341,7 @@ type /// que le proprietaire ne connaitrait pas. procedure SetUnlockCode(const ANew: string); procedure PushUnlockMode; + function PwdName: string; /// Va chercher l'icone du site de l'entree ouverte, ou l'efface. procedure SetEntryIcon(AFetch: Boolean); /// Le depot a bouge, ou ne l'a plus : LE DRAPEAU ET SON TEMOIN ENSEMBLE. @@ -545,7 +546,7 @@ begin if LCanOpen then begin if FRecover then - Status('Screen lock changed - type your vault password') + Status('Screen lock changed - type your ' + PwdName) else if VaultNeedsPin then Status('Vault on this device - unlock code required') else if VaultNeedsAuth then @@ -1807,7 +1808,7 @@ begin // que l'utilisateur ne retapera jamais a l'identique. if (Param('pw') = '1') and ((FPlain = '') or (TNetEncoding.URL.Decode(Param('c')) <> CachePwd)) then - WebCall('PM.toast("Wrong vault password")') + WebCall('PM.toast("Wrong ' + PwdName + '")') else SetUnlockCode(TNetEncoding.URL.Decode(Param('c'))); end @@ -2304,7 +2305,7 @@ begin begin Log('Recovery copy did not open under this password'); ShowUnlock; - StatusErr('Wrong vault password'); + StatusErr('Wrong ' + PwdName); WebCall('PM.focusPin()'); Exit; end; @@ -2315,7 +2316,7 @@ begin FRecover := True; Log('Screen lock key destroyed - recovery copy available'); ShowUnlock; - StatusErr('Screen lock changed - type your vault password'); + StatusErr('Screen lock changed - type your ' + PwdName); WebCall('PM.focusPin()'); Exit; end; @@ -2380,7 +2381,7 @@ begin begin if FPin = '' then begin - StatusErr('Screen lock changed - type your vault password'); + StatusErr('Screen lock changed - type your ' + PwdName); WebCall('PM.focusPin()'); Exit; end; @@ -3188,6 +3189,14 @@ begin LowerCase(BoolToStr(HasLocalContainer, True))])); end; +/// LE BON NOM POUR LE MOT DE PASSE QUI OUVRE CE COFFRE. Un coffre venu de la +/// synchro s'ouvre au mot de passe de synchro ; l'appeler "vault password" +/// envoyait chercher un mot de passe qui n'existe pas. +function TForm8.PwdName: string; +begin + if HasLocalContainer then Result := 'vault password' else Result := 'sync password'; +end; + function TForm8.CachePwd: string; begin if HasLocalContainer then Result := FVaultPwd else Result := FSyncPwd;