From a2dbb896c130e10eed05913cf31a56be45dc3495 Mon Sep 17 00:00:00 2001 From: abonadon_hk Date: Mon, 22 Apr 2024 15:02:33 +0800 Subject: [PATCH] add: add pinExpired Signed-off-by: abonadon_hk --- entry/src/main/ets/common/vm/Constants.ts | 2 ++ entry/src/main/ets/pages/components/FaceAuth.ets | 13 ++++++++++++- .../main/ets/pages/components/FingerprintAuth.ets | 7 ++++++- .../src/main/ets/pages/components/PasswordAuth.ets | 6 ++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/entry/src/main/ets/common/vm/Constants.ts b/entry/src/main/ets/common/vm/Constants.ts index b29cff1..805d58e 100644 --- a/entry/src/main/ets/common/vm/Constants.ts +++ b/entry/src/main/ets/common/vm/Constants.ts @@ -32,6 +32,8 @@ export default class Constants { static userAuthWidgetMgrVersion = 1; // command result success static userAuthWidgetMgrSuccess = 0; + // auth result that pin expired from auth service + static authResultPinExpired: number = 13; // sendNotice params // version diff --git a/entry/src/main/ets/pages/components/FaceAuth.ets b/entry/src/main/ets/pages/components/FaceAuth.ets index 9219c1c..67fe200 100644 --- a/entry/src/main/ets/pages/components/FaceAuth.ets +++ b/entry/src/main/ets/pages/components/FaceAuth.ets @@ -197,6 +197,11 @@ export default struct FaceAuth { if (payload.type === Constants.noticeTypePin) { if (payload.result === 0) { (AppStorage.get("session") as UIExtensionContentSession)?.terminateSelf(); + } else if (payload.result && payload.result === Constants.authResultPinExpired) { + this.inputValue = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id); + this.textValue = ''; + return; } else { if (payload.remainAttempts) { this.inputValue = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager @@ -223,6 +228,12 @@ export default struct FaceAuth { if ([SIX_PIN, MULTI_PIN].includes(this.dialogTypeFlag)) { return; } + if (payload.result && payload.result === Constants.authResultPinExpired) { + this.prompt = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1').id); + this.faceLock = false; + return; + } if (payload.remainAttempts && payload.result !== 0) { this.prompt = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager .getStringSync($r('app.string.unified_authwidget_hint_face_verify_fail_click_retry_s1').id); @@ -281,7 +292,7 @@ export default struct FaceAuth { break; } } - if (payload.remainAttempts && payload.result !== 0) { + if ((payload.remainAttempts && payload.result !== 0) || payload.result === Constants.authResultPinExpired) { this.prompt = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id); this.fingerLock = false; diff --git a/entry/src/main/ets/pages/components/FingerprintAuth.ets b/entry/src/main/ets/pages/components/FingerprintAuth.ets index ce9e509..f04cfc2 100644 --- a/entry/src/main/ets/pages/components/FingerprintAuth.ets +++ b/entry/src/main/ets/pages/components/FingerprintAuth.ets @@ -119,6 +119,11 @@ export default struct FingerprintAuth { if (payload.type === Constants.noticeTypePin) { if (payload.result === 0) { (AppStorage.get("session") as UIExtensionContentSession)?.terminateSelf(); + } else if (payload.result && payload.result === Constants.authResultPinExpired){ + this.inputValue = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id); + this.textValue = ''; + return; } else { if (payload.remainAttempts) { this.inputValue = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager @@ -165,7 +170,7 @@ export default struct FingerprintAuth { break; } } - if (payload.remainAttempts && payload.result !== 0) { + if ((payload.remainAttempts && payload.result !== 0) || payload.result === Constants.authResultPinExpired) { this.prompt = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager .getStringSync($r('app.string.unified_authwidget_hint_fp_retry_s2').id); this.fingerLock = false; diff --git a/entry/src/main/ets/pages/components/PasswordAuth.ets b/entry/src/main/ets/pages/components/PasswordAuth.ets index e252290..8e9868e 100644 --- a/entry/src/main/ets/pages/components/PasswordAuth.ets +++ b/entry/src/main/ets/pages/components/PasswordAuth.ets @@ -53,6 +53,12 @@ export default struct PasswordAuth { this.cmdData.length > 0 && this.cmdData.map((item) => { const payload: CmdData = item.payload; if (payload.type === Constants.noticeTypePin) { + if (payload.result && payload.result === Constants.authResultPinExpired) { + this.inputValue = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager + .getStringSync($r('app.string.unified_authwidget_hint_unified_authwidget_hint_pwd_errorpwd_error').id); + this.textValue = ''; + return; + } if (payload.remainAttempts && payload.remainAttempts < MAX_FAIL_TIMES) { this.inputValue = (AppStorage.get("context") as common.ExtensionContext)?.resourceManager .getStringSync($r('app.string.unified_authwidget_hint_pwd_error').id); -- Gitee