Skip to content

Commit

Permalink
✨ feat(frontend): Add function to grant biometric access
Browse files Browse the repository at this point in the history
Added a new function `grantBiometricAccess` to handle the process of requesting biometric access and displaying alerts based on the user's decision. This function is called when biometric access is not already granted. Updated the logic for handling biometric initialization and access verification.

Refactored code in `App.vue` to improve biometric authentication flow.

See details in the diff for more information.

Closes #32
Co-authored-by: John Doe <[email protected]>
  • Loading branch information
sudoskys committed May 12, 2024
1 parent d685d82 commit 65c57eb
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ const authSuccess = () => {
verifyBackendMessage.message = 'Backend verification error'
})
}
const grantBiometricAccess = () => {
WebAppBiometricManager.requestBiometricAccess(
{reason: 'Please authenticate to continue'},
(isAccessGranted: boolean) => {
if (isAccessGranted) {
console.log('Biometric access granted')
WebApp.close()
} else {
console.log('Biometric access denied')
WebAppPopup.showAlert('Biometric access denied, you can click settings to open the settings')
}
}
)
}
// 逻辑区域
Expand All @@ -166,6 +180,13 @@ WebAppBiometricManager.initBiometric(
console.log('Biometric now available')
console.log(WebAppBiometricManager.biometricType.value)
isBiometricInitialized.value = true
// 授权
if (WebAppBiometricManager.isBiometricAccessGranted.value) {
console.log('Biometric granted')
} else {
console.log('Biometric not granted')
grantBiometricAccess()
}
} else {
console.log('Biometric now unavailable')
isBiometricInitialized.value = false
Expand All @@ -174,25 +195,6 @@ WebAppBiometricManager.initBiometric(
}
)
// 授权
if (WebAppBiometricManager.isBiometricAccessGranted.value) {
console.log('Biometric granted')
} else {
console.log('Biometric not granted')
WebAppBiometricManager.requestBiometricAccess(
{reason: 'Please authenticate to continue'},
(isAccessGranted: boolean) => {
if (isAccessGranted) {
console.log('Biometric access granted')
WebApp.close()
} else {
console.log('Biometric access denied')
WebAppPopup.showAlert('Biometric access denied, you can click settings to open the settings')
}
}
)
}
console.log(getUserAcc())
WebApp.ready()
Expand Down

0 comments on commit 65c57eb

Please sign in to comment.