face id/touch id supports ios safari

This commit is contained in:
MaysWind
2020-11-22 23:53:52 +08:00
parent ae5af160c9
commit dc78f5fa7e
4 changed files with 43 additions and 23 deletions
+24 -10
View File
@@ -3,11 +3,12 @@
<f7-login-screen-title>{{ $t('PIN Code') }}</f7-login-screen-title>
<f7-list form>
<f7-list-item class="list-item-pincode-input">
<PincodeInput secure :length="6" v-model="pinCode" @keyup.native="unlock" />
<PincodeInput secure :length="6" v-model="pinCode" @keyup.native="unlockByPin" />
</f7-list-item>
</f7-list>
<f7-list>
<f7-list-button :class="{ 'disabled': !pinCodeValid }" :text="$t('Unlock')" @click="unlock"></f7-list-button>
<f7-list-button :class="{ 'disabled': !pinCodeValid }" :text="$t('Unlock By PIN Code')" @click="unlockByPin"></f7-list-button>
<f7-list-button v-if="isWebAuthnAvailable" :text="$t('Unlock By Face ID/Touch ID')" @click="unlockByWebAuthn"></f7-list-button>
<f7-block-footer>
<f7-link :text="$t('Re-login')" @click="relogin"></f7-link>
</f7-block-footer>
@@ -23,15 +24,30 @@ export default {
}
},
computed: {
isWebAuthnAvailable() {
return this.$settings.isEnableApplicationLockWebAuthn()
&& this.$user.getWebAuthnCredentialId()
&& this.$webauthn.isSupported();
},
pinCodeValid() {
return this.pinCode && this.pinCode.length === 6;
}
},
created() {
const self = this;
const router = self.$f7router;
methods: {
unlockByWebAuthn() {
const self = this;
const router = self.$f7router;
if (!self.$settings.isEnableApplicationLockWebAuthn() || !self.$user.getWebAuthnCredentialId()) {
self.$toast('Face ID/Touch ID authentication is not enabled');
return;
}
if (!self.$webauthn.isSupported()) {
self.$toast('This device does not support Face ID/Touch ID');
return;
}
if (self.$settings.isEnableApplicationLockWebAuthn() && self.$user.getWebAuthnCredentialId()) {
self.$showLoading();
self.$webauthn.verifyCredential(
@@ -62,10 +78,8 @@ export default {
self.$toast('User has canceled or this device does not support Face ID/Touch ID');
}
});
}
},
methods: {
unlock() {
},
unlockByPin() {
const app = this.$f7;
const $$ = app.$;