mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-01-31 00:45:24 +01:00
fix(biometric) prompt for fallback credentials when enabled and biometry unavailable on iOS (fix #2632) (#2633)
This commit is contained in:
6
.changes/fix-ios-biometry-fallback-auth.md
Normal file
6
.changes/fix-ios-biometry-fallback-auth.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"biometric": patch:bug
|
||||
"biometric-js": patch:bug
|
||||
---
|
||||
|
||||
Fix biometric plugin ignoring fallback logic when biometry status is unavailable or not enrolled on iOS.
|
||||
@@ -98,7 +98,12 @@ class BiometricPlugin: Plugin {
|
||||
}
|
||||
|
||||
@objc func authenticate(_ invoke: Invoke) throws {
|
||||
guard self.status.available else {
|
||||
let args = try invoke.parseArgs(AuthOptions.self)
|
||||
|
||||
let allowDeviceCredential = args.allowDeviceCredential ?? false
|
||||
|
||||
guard self.status.available || allowDeviceCredential else {
|
||||
// Biometry unavailable, fallback disabled
|
||||
invoke.reject(
|
||||
self.status.errorReason ?? "",
|
||||
code: self.status.errorCode ?? ""
|
||||
@@ -106,15 +111,11 @@ class BiometricPlugin: Plugin {
|
||||
return
|
||||
}
|
||||
|
||||
let args = try invoke.parseArgs(AuthOptions.self)
|
||||
|
||||
let context = LAContext()
|
||||
context.localizedFallbackTitle = args.fallbackTitle
|
||||
context.localizedCancelTitle = args.cancelTitle
|
||||
context.touchIDAuthenticationAllowableReuseDuration = 0
|
||||
|
||||
let allowDeviceCredential = args.allowDeviceCredential ?? false
|
||||
|
||||
// force system default fallback title if an empty string is provided (the OS hides the fallback button in this case)
|
||||
if allowDeviceCredential,
|
||||
let fallbackTitle = context.localizedFallbackTitle,
|
||||
|
||||
Reference in New Issue
Block a user