Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
removePin() {
//PinDialog.prompt('請輸入密碼', '關閉密碼', ['確認', '取消'])
PinDialog.prompt(this.RemovePinPromptMsg,this.RemovePinTitle, [this.RemovePinConfirmBtn, this.RemovePinCancelBtn])
.then((result: any) => {
if (result.input1 === this.configServ.getUserPin()) {
this.storage.set('userPin', '');
this.userPin = '';
this.configServ.setUserPin('');
this.configServ.setPauseEmitted('N');
this.enableLock = !this.enableLock;
this.toastMessage(this.RemovePinDoneMsg); // 密碼鎖已關閉
} else {
this.toastMessage(this.RemovePinAlertMsg); // 密碼錯誤
}
});
}
var _this = this;
var canEnter = false;
var message; // 請輸入密碼
var title; // 解除密碼鎖
var btnConfirm; // 確認
var btnCancel; // 取消
var alertMessageSuccess; // 成功解除密碼鎖
var alertMessageError; // 密碼錯誤
this.localServ.localize('CONFIG_SERV.MESSAGE', function (value) { message = value; });
this.localServ.localize('CONFIG_SERV.TITLE', function (value) { title = value; });
this.localServ.localize('CONFIG_SERV.BTN_CONFIRM', function (value) { btnConfirm = value; });
this.localServ.localize('CONFIG_SERV.BTN_CANCEL', function (value) { btnCancel = value; });
this.localServ.localize('CONFIG_SERV.ALERT_MSG_SUCCESS', function (value) { alertMessageSuccess = value; });
this.localServ.localize('CONFIG_SERV.ALERT_MSG_ERROR', function (value) { alertMessageError = value; });
if (this.getPauseEmitted() === 'Y' && this.getUserPin().length >= 4) {
PinDialog.prompt(message, title, [btnConfirm, btnCancel])
.then(function (result) {
if (result.buttonIndex === 1) {
if (result.input1 === _this.getUserPin()) {
_this.alertMessage(alertMessageSuccess);
_this.setPauseEmitted('N');
canEnter = true;
}
else {
_this.alertMessage(alertMessageError);
canEnter = false;
}
}
else {
canEnter = false;
}
});
confirmPin(pin: string) {
//PinDialog.prompt('請重複輸入密碼', '確認密碼', ['確認', '取消'])
PinDialog.prompt(this.ConfirmPinPromptMsg, this.ConfirmPinTitle, [this.ConfirmPinConfirmBtn, this.ConfirmPinCancelBtn])
.then((result: any) => {
if (result.buttonIndex === 1) {
if (result.input1 === pin) {
this.userPin = result.input1;
this.storage.set('userPin', this.userPin);
this.configServ.setUserPin(this.userPin);
this.configServ.setPauseEmitted('N');
this.enableLock = !this.enableLock;
this.toastMessage(this.ConfirmPinDoneMsg); // 密碼鎖已開啟
} else {
this.toastMessage(this.ConfirmPinAlertMsg); // 密碼不一致,請重新設定
}
}
});
}
addPin() {
//PinDialog.prompt('請輸入至少4個數字的密碼', '設定密碼', ['確認', '取消'])
PinDialog.prompt(this.addPinPromptMsg, this.addPinTitle, [this.addPinConfirmBtn, this.addPinCancelBtn])
.then((result: any) => {
if (result.buttonIndex === 1) {
if (result.input1 !== null && result.input1.trim().length >= 4) {
this.confirmPin(result.input1);
} else {
this.toastMessage(this.addPinPromptMsg); // 請輸入至少4個數字的密碼
}
}
});
}
PinConfigPage.prototype.addPin = function () {
var _this = this;
//PinDialog.prompt('請輸入至少4個數字的密碼', '設定密碼', ['確認', '取消'])
PinDialog.prompt(this.addPinPromptMsg, this.addPinTitle, [this.addPinConfirmBtn, this.addPinCancelBtn])
.then(function (result) {
if (result.buttonIndex === 1) {
if (result.input1 !== null && result.input1.trim().length >= 4) {
_this.confirmPin(result.input1);
}
else {
_this.alertMessage(_this.addPinAlertMsg);
}
}
});
};
PinConfigPage.prototype.confirmPin = function (pin) {
PinConfigPage.prototype.confirmPin = function (pin) {
var _this = this;
//PinDialog.prompt('請重複輸入密碼', '確認密碼', ['確認', '取消'])
PinDialog.prompt(this.ConfirmPinPromptMsg, this.ConfirmPinTitle, [this.ConfirmPinConfirmBtn, this.ConfirmPinCancelBtn])
.then(function (result) {
if (result.buttonIndex === 1) {
if (result.input1 === pin) {
_this.storage.set('userPin', result.input1);
_this.userPin = result.input1;
_this.configServ.setUserPin(result.input1);
_this.configServ.setPauseEmitted('Y');
_this.enableLock = !_this.enableLock;
_this.appCtrl.getRootNav().setRoot(HomePage);
}
else {
_this.alertMessage(_this.ConfirmPinAlertMsg);
}
}
});
};
unlockScreen(): boolean {
let canEnter: boolean = false;
if (this.getPauseEmitted() === 'Y' && this.getUserPin().length >= 4) {
PinDialog.prompt('請輸入密碼', '解除密碼鎖', ['確認', '取消'])
.then((result: any) => {
if (result.buttonIndex === 1) {
if (result.input1 === this.getUserPin()) {
this.toastMessage('成功解除密碼鎖');
this.setPauseEmitted('N');
canEnter = true;
} else {
this.toastMessage('密碼錯誤');
canEnter = false;
}
} else {
canEnter = false;
}
});
} else {
canEnter = true;
PinConfigPage.prototype.removePin = function () {
var _this = this;
//PinDialog.prompt('請輸入密碼', '關閉密碼', ['確認', '取消'])
PinDialog.prompt(this.RemovePinPromptMsg, this.RemovePinTitle, [this.RemovePinConfirmBtn, this.RemovePinCancelBtn])
.then(function (result) {
if (result.input1 === _this.configServ.getUserPin()) {
_this.storage.set('userPin', '');
_this.userPin = '';
_this.configServ.setUserPin('');
_this.configServ.setPauseEmitted('N');
_this.enableLock = !_this.enableLock;
_this.appCtrl.getRootNav().setRoot(HomePage);
}
else {
_this.alertMessage(_this.RemovePinAlertMsg);
}
});
};
PinConfigPage.prototype.alertMessage = function (msg) {