user need input current pin code when disable application lock

This commit is contained in:
MaysWind
2020-11-21 12:24:27 +08:00
parent 218f8e8fec
commit 414084e6b9
4 changed files with 70 additions and 6 deletions
+56 -6
View File
@@ -9,7 +9,7 @@
<f7-card-content :padding="false">
<f7-list>
<f7-list-item :title="$t('Status')" :after="$t('Enabled')"></f7-list-item>
<f7-list-button @click="disable">{{ $t('Disable') }}</f7-list-button>
<f7-list-button @click="disable(null)">{{ $t('Disable') }}</f7-list-button>
</f7-list>
</f7-card-content>
</f7-card>
@@ -38,13 +38,36 @@
<PincodeInput secure :length="6" v-model="currentPinCodeForEnable" />
</f7-list-item>
</f7-list>
<f7-button large fill :class="{ 'disabled': !currentPinCodeValid }" :text="$t('Continue')" @click="enable(currentPinCodeForEnable)"></f7-button>
<f7-button large fill :class="{ 'disabled': !currentPinCodeForEnableValid }" :text="$t('Continue')" @click="enable(currentPinCodeForEnable)"></f7-button>
<div class="margin-top text-align-center">
<f7-link @click="showInputPinCodeSheetForEnable = false" :text="$t('Cancel')"></f7-link>
</div>
</div>
</f7-page-content>
</f7-sheet>
<f7-sheet
style="height:auto;"
:opened="showInputPinCodeSheetForDisable" @sheet:closed="showInputPinCodeSheetForDisable = false; currentPinCodeForDisable = ''"
>
<f7-page-content>
<div class="display-flex padding justify-content-space-between align-items-center">
<div style="font-size: 18px"><b>{{ $t('PIN Code') }}</b></div>
</div>
<div class="padding-horizontal padding-bottom">
<p class="no-margin-top margin-bottom-half">{{ $t('Please enter your current PIN code when disable application lock') }}</p>
<f7-list no-hairlines class="no-margin-top margin-bottom">
<f7-list-item class="list-item-pincode-input">
<PincodeInput secure :length="6" v-model="currentPinCodeForDisable" />
</f7-list-item>
</f7-list>
<f7-button large fill :class="{ 'disabled': !currentPinCodeForDisableValid }" :text="$t('Continue')" @click="disable(currentPinCodeForDisable)"></f7-button>
<div class="margin-top text-align-center">
<f7-link @click="showInputPinCodeSheetForDisable = false" :text="$t('Cancel')"></f7-link>
</div>
</div>
</f7-page-content>
</f7-sheet>
</f7-page>
</template>
@@ -54,22 +77,32 @@ export default {
return {
isEnableApplicationLock: this.$settings.isEnableApplicationLock(),
currentPinCodeForEnable: '',
showInputPinCodeSheetForEnable: false
currentPinCodeForDisable: '',
showInputPinCodeSheetForEnable: false,
showInputPinCodeSheetForDisable: false
};
},
computed: {
currentPinCodeValid() {
currentPinCodeForEnableValid() {
return this.currentPinCodeForEnable && this.currentPinCodeForEnable.length === 6;
},
currentPinCodeForDisableValid() {
return this.currentPinCodeForDisable && this.currentPinCodeForDisable.length === 6;
}
},
methods: {
enable(pinCode) {
if (this.$settings.isEnableApplicationLock()) {
this.$alert('Application lock has been enabled');
return;
}
if (!pinCode) {
this.showInputPinCodeSheetForEnable = true;
return;
}
if (!this.currentPinCodeValid) {
if (!this.currentPinCodeForEnableValid) {
this.$alert('PIN code is invalid');
return;
}
@@ -80,10 +113,27 @@ export default {
this.showInputPinCodeSheetForEnable = false;
},
disable() {
disable(pinCode) {
if (!this.$settings.isEnableApplicationLock()) {
this.$alert('Application lock is not enabled');
return;
}
if (!pinCode) {
this.showInputPinCodeSheetForDisable = true;
return;
}
if (!this.$user.isCorrectPinCode(pinCode)) {
this.$alert('PIN code is wrong');
return;
}
this.$user.decryptToken();
this.$settings.setEnableApplicationLock(false);
this.isEnableApplicationLock = false;
this.showInputPinCodeSheetForDisable = false;
}
}
}