From 68a6af0a426e59562e74787c7850d0ada95fd347 Mon Sep 17 00:00:00 2001 From: cania Date: Thu, 13 Aug 2026 10:45:53 +0200 Subject: [PATCH] Diagnose biometric: show real error on retry, disable sensitiveTransaction, enable useErrorDialogs for reliable OS prompt --- lib/auth_screen.dart | 21 +++++++++++++++++---- lib/auth_service.dart | 10 ++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/auth_screen.dart b/lib/auth_screen.dart index 4ed7d7e..aff655a 100644 --- a/lib/auth_screen.dart +++ b/lib/auth_screen.dart @@ -70,6 +70,22 @@ class _AuthScreenState extends State { } } + /// Manual retry via button: show the REAL error so we can diagnose + /// why the OS dialog didn't appear. + Future _retryBiometric() async { + setState(() => _bioMsg = null); + final (ok, err) = await widget.auth.authenticateWithBiometrics(); + if (!mounted) return; + if (ok) { + final email = await widget.auth.getEmail() ?? ''; + _goToDashboard(email); + } else { + setState(() { + _bioMsg = 'Sidik jari gagal: ${err ?? "dibatalkan"}'; + }); + } + } + /// On open: if a valid session is present, go straight to Dashboard. Future _trySilentAuth() async { final timeout = await widget.auth.getTimeoutMinutes(); @@ -173,10 +189,7 @@ class _AuthScreenState extends State { _biometricAvailable && _biometricEnabled) TextButton.icon( - onPressed: () { - setState(() => _bioMsg = null); - _promptBiometricOnOpen(); - }, + onPressed: _retryBiometric, icon: const Icon(Icons.fingerprint), label: const Text('Gunakan Sidik Jari'), ), diff --git a/lib/auth_service.dart b/lib/auth_service.dart index c905072..4f0f9c3 100644 --- a/lib/auth_service.dart +++ b/lib/auth_service.dart @@ -61,9 +61,15 @@ class AuthService { // device credentials (PIN/pattern) so the user isn't hard-blocked. for (final opt in [ const AuthenticationOptions( - biometricOnly: true, stickyAuth: true, sensitiveTransaction: true), + biometricOnly: true, + stickyAuth: true, + sensitiveTransaction: false, + useErrorDialogs: true), const AuthenticationOptions( - biometricOnly: false, stickyAuth: true, sensitiveTransaction: true), + biometricOnly: false, + stickyAuth: true, + sensitiveTransaction: false, + useErrorDialogs: true), ]) { try { final ok = await _localAuth.authenticate(