feat(totp): scanner le QR 2FA affiche a l'ecran (capture + ZXing), seul un otpauth:// part vers la page
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,7 @@ uses
|
||||
FMX.TMSFNCEdgeWebBrowser,
|
||||
{$ENDIF}
|
||||
PM.HTTPServer, PM.Bridge, PM.QuickUnlock, PM.PinUnlock, PM.UserPrefs, PM.Licence, PM.AutoStart,
|
||||
PM.Favicon, DelphiZXingQRCode,
|
||||
PM.Favicon, DelphiZXingQRCode, PM.ScreenQr,
|
||||
FMX.Platform.Win, FMX.Menus; // WindowHandleToPlatform → HWND for visibility check
|
||||
const
|
||||
// Bump on each release. Surfaced to JS via cmd://app/version, displayed
|
||||
@@ -1393,6 +1393,40 @@ begin
|
||||
// envoie tout texte a une recherche web (Google, Chrome) - le jeton serait
|
||||
// parti chez Google a un appui pres. Un lien a schema propre n'a qu'une
|
||||
// application pour l'ouvrir : la notre.
|
||||
// QR 2FA affiche par un site : la fenetre s'efface le temps de la capture
|
||||
// (elle recouvre souvent le QR), puis revient. Seul un lien otpauth:// part
|
||||
// vers la page - le reste de l'ecran ne quitte pas la memoire de l'exe.
|
||||
else if ACmd = 'qr/screen' then
|
||||
begin
|
||||
LogLine('qr/screen: scanning');
|
||||
FBridge.MinimizeToTray(False, False);
|
||||
TThread.CreateAnonymousThread(
|
||||
procedure
|
||||
var
|
||||
LText: string;
|
||||
begin
|
||||
Sleep(400); // laisser Windows retirer la fenetre de l'ecran
|
||||
LText := ScanScreenForQr;
|
||||
if Pos('otpauth://', LowerCase(LText)) <> 1 then LText := '';
|
||||
TThread.Queue(nil,
|
||||
procedure
|
||||
var
|
||||
LJs: TJSONString;
|
||||
begin
|
||||
RestoreWindowFromTray;
|
||||
if LText = '' then LogLine('qr/screen: no otpauth QR found')
|
||||
else LogLine('qr/screen: otpauth QR found');
|
||||
LJs := TJSONString.Create(LText);
|
||||
try
|
||||
WebBrowser.ExecuteJavaScript(
|
||||
'if(window.Bridge&&Bridge.onScreenQr)Bridge.onScreenQr(' + LJs.ToJSON + ')');
|
||||
finally
|
||||
LJs.Free;
|
||||
end;
|
||||
end);
|
||||
end).Start;
|
||||
end
|
||||
|
||||
else if ACmd = 'sync/qr' then
|
||||
begin
|
||||
var LQrUrl := PM.UserPrefs.GetPref('syncUrl');
|
||||
|
||||
Reference in New Issue
Block a user