fix(qr): dire "ce QR n'est pas un code 2FA" au lieu de "aucun QR"
Un QR de texte, ou un QR dynamique qui encode un lien de suivi, etait lu puis ecarte en silence : l'exe repondait "aucun QR 2FA trouve", l'APK continuait de viser sans rien dire. Le texte d'un autre QR ne part toujours pas a la page ; seul le fait qu'un QR a ete lu est signale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1404,9 +1404,14 @@ begin
|
|||||||
procedure
|
procedure
|
||||||
var
|
var
|
||||||
LText: string;
|
LText: string;
|
||||||
|
LFound: Boolean;
|
||||||
begin
|
begin
|
||||||
Sleep(400); // laisser Windows retirer la fenetre de l'ecran
|
Sleep(400); // laisser Windows retirer la fenetre de l'ecran
|
||||||
LText := ScanScreenForQr;
|
LText := ScanScreenForQr;
|
||||||
|
// UN QR LU N'EST PAS UN QR DE 2FA. Le texte d'un autre QR ne part pas a
|
||||||
|
// la page - il n'a rien a y faire -, mais le FAIT qu'un QR a ete lu,
|
||||||
|
// si : "aucun QR" alors qu'il y en avait un envoyait chercher ailleurs.
|
||||||
|
LFound := LText <> '';
|
||||||
if Pos('otpauth://', LowerCase(LText)) <> 1 then LText := '';
|
if Pos('otpauth://', LowerCase(LText)) <> 1 then LText := '';
|
||||||
TThread.Queue(nil,
|
TThread.Queue(nil,
|
||||||
procedure
|
procedure
|
||||||
@@ -1414,12 +1419,14 @@ begin
|
|||||||
LJs: TJSONString;
|
LJs: TJSONString;
|
||||||
begin
|
begin
|
||||||
RestoreWindowFromTray;
|
RestoreWindowFromTray;
|
||||||
if LText = '' then LogLine('qr/screen: no otpauth QR found')
|
if LText <> '' then LogLine('qr/screen: otpauth QR found')
|
||||||
else LogLine('qr/screen: otpauth QR found');
|
else if LFound then LogLine('qr/screen: a QR code, but not a 2FA one')
|
||||||
|
else LogLine('qr/screen: no QR code on screen');
|
||||||
LJs := TJSONString.Create(LText);
|
LJs := TJSONString.Create(LText);
|
||||||
try
|
try
|
||||||
WebBrowser.ExecuteJavaScript(
|
WebBrowser.ExecuteJavaScript(
|
||||||
'if(window.Bridge&&Bridge.onScreenQr)Bridge.onScreenQr(' + LJs.ToJSON + ')');
|
'if(window.Bridge&&Bridge.onScreenQr)Bridge.onScreenQr(' + LJs.ToJSON
|
||||||
|
+ ',' + BoolToStr(LFound, True).ToLower + ')');
|
||||||
finally
|
finally
|
||||||
LJs.Free;
|
LJs.Free;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -4839,9 +4839,13 @@ function soTotpField(plainSecret) {
|
|||||||
const scan = el('button', { class: 'icon-btn icon-btn-sm', type: 'button', title: 'Scan the 2FA QR code shown on screen' });
|
const scan = el('button', { class: 'icon-btn icon-btn-sm', type: 'button', title: 'Scan the 2FA QR code shown on screen' });
|
||||||
scan.appendChild(icon('i-qr'));
|
scan.appendChild(icon('i-qr'));
|
||||||
scan.addEventListener('click', () => {
|
scan.addEventListener('click', () => {
|
||||||
Bridge.onScreenQr = (text) => {
|
Bridge.onScreenQr = (text, found) => {
|
||||||
const secret = parseOtpAuthUri(text || '');
|
const secret = parseOtpAuthUri(text || '');
|
||||||
if (!secret) { toast('No 2FA QR code found on screen', 'warning'); return; }
|
if (!secret) {
|
||||||
|
toast(found ? 'This QR code is not a 2FA code (it has no otpauth:// link)'
|
||||||
|
: 'No QR code found on screen', 'warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
input.value = secret;
|
input.value = secret;
|
||||||
updateTotpDisplay();
|
updateTotpDisplay();
|
||||||
soDirtyCheck();
|
soDirtyCheck();
|
||||||
|
|||||||
@@ -3898,8 +3898,16 @@ begin
|
|||||||
StopScan;
|
StopScan;
|
||||||
ApplySyncLink(Trim(Copy(LText, Pos('pmserver://sync?', LText), MaxInt)));
|
ApplySyncLink(Trim(Copy(LText, Pos('pmserver://sync?', LText), MaxInt)));
|
||||||
end
|
end
|
||||||
|
// UN QR LU, MAIS PAS LE BON. On continue de viser - plusieurs QR
|
||||||
|
// peuvent etre dans le champ - et le bandeau dit pourquoi rien ne
|
||||||
|
// se passe, au lieu d'un scan qui semble ne rien voir.
|
||||||
|
else if FScanTotp then
|
||||||
|
FScanLbl.Text := 'This QR code is not a 2FA code - aim at the one the site shows'
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
|
FScanLbl.Text := 'This QR code is not the one shown by the PC';
|
||||||
Log('QR scan: not a sync link, first char code ' + IntToStr(Ord(LText[1])));
|
Log('QR scan: not a sync link, first char code ' + IntToStr(Ord(LText[1])));
|
||||||
|
end;
|
||||||
end);
|
end);
|
||||||
end).Start;
|
end).Start;
|
||||||
end);
|
end);
|
||||||
|
|||||||
Reference in New Issue
Block a user