biometricPermission&Authentication
This commit is contained in:
@@ -82,39 +82,4 @@ class AuthService {
|
||||
throw AuthException('Error fetching user profile: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> authenticateWithBiometrics(BuildContext context) async {
|
||||
final LocalAuthentication localAuth = LocalAuthentication();
|
||||
try {
|
||||
bool isBiometricAvailable = await localAuth.canCheckBiometrics;
|
||||
bool isAuthenticated = false;
|
||||
|
||||
if (isBiometricAvailable) {
|
||||
isAuthenticated = await localAuth.authenticate(
|
||||
localizedReason: 'Touch the fingerprint sensor',
|
||||
options: const AuthenticationOptions(
|
||||
biometricOnly: true,
|
||||
stickyAuth: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (isAuthenticated) {
|
||||
// Navigate to Dashboard
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const NavigationScaffold()),
|
||||
);
|
||||
} else {
|
||||
// Show error/snack bar
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("Authentication failed")),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
print("Biometric error: $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user