diff --git a/UserAuthentication/README.md b/UserAuthentication/README.md index b995722a700d0678b4ec1428e81f3b5e886c9204..ecda66aff89dc63e62a0cd9add6a3f85f9faf178 100644 --- a/UserAuthentication/README.md +++ b/UserAuthentication/README.md @@ -7,8 +7,8 @@ ### 效果预览 | 首页 | 实例1 | 用户验证窗口 | -| -------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------ | -| | | | +| -------------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- | +| | | | 使用说明: diff --git a/UserAuthentication/build-profile.json5 b/UserAuthentication/build-profile.json5 index e395c7252dcbc4351e7b2251d9db371c55567d76..8ff2e50e6bd0421e70242107435c6f928a0d08cc 100644 --- a/UserAuthentication/build-profile.json5 +++ b/UserAuthentication/build-profile.json5 @@ -19,8 +19,8 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "6.0.0(20)", - "targetSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.2(22)", + "targetSdkVersion": "6.0.2(22)", "runtimeOS": "HarmonyOS" } ], diff --git a/UserAuthentication/entry/src/main/ets/pages/Index.ets b/UserAuthentication/entry/src/main/ets/pages/Index.ets index 181eaeaf1897654bd2af98167c4be6a72a8cd83e..b3ac8c2df756a564017649a121011833ec233534 100644 --- a/UserAuthentication/entry/src/main/ets/pages/Index.ets +++ b/UserAuthentication/entry/src/main/ets/pages/Index.ets @@ -67,7 +67,7 @@ enum PageIndex { EXAMPLE_TAB_4 = 5, // 自定义页面的索引值 CREDENTIAL_QUERIES = 6, // 查询凭据页面的索引值 SIMULATION_VALIDATION = 7, // 模拟认证页面的索引值 - + AUTH_LOCK_STATE_QUERIES = 8, // 查询认证冻结状态页面的索引值 }; enum ResultIndex { @@ -90,6 +90,7 @@ struct Index { @State credentialDigest: string = ''; @State whetherSupport: Resource = $r('app.string.waitQuery'); @State credentialValue: string = ''; + @State authLockStateContent : string = ''; SPACE_GAP: number = 5; // Row组件间隙 /* @@ -557,6 +558,30 @@ struct Index { } // [End obtain_enrolled_capabilities] + + /* + * obtain-auth-lock-state-capabilities.md + * 以查询用户PIN码认证类型的认证冻结状态为例 + * */ + // [Start obtain_auth_lock_state_capabilities] + async obtainingAuthLockState() : Promise { + try { + Logger.info(`get auth lock state start`); + const authLockState : userAuth.AuthLockState = await userAuth.getAuthLockState(userAuth.UserAuthType.PIN); + if (authLockState.lockoutDuration === userAuth.PERMANENT_LOCKOUT_DURATION) { + Logger.info('the authentication of given authType is permanent locked'); + } + const authLockStateContent : string = JSON.stringify(authLockState); + Logger.info(`get auth lock state success, authLockState is: ${authLockStateContent}`); + return authLockStateContent; + } catch (error) { + const errorMessage : string = `get auth lock state failed, err code is : ${error?.code}, err message is : ${error?.message}`; + Logger.error(errorMessage); + return errorMessage; + } + } + + // [End obtain_auth_lock_state_capabilities] comprehensiveFeatures() { let reuseUnlockResult: userAuth.ReuseUnlockResult = { reuseMode: userAuth.ReuseMode.AUTH_TYPE_RELEVANT, @@ -806,6 +831,24 @@ struct Index { } .tabBar(this.tabBuilder($r('app.string.simulationValidation'), PageIndex.SIMULATION_VALIDATION, 'simulationValidation')) + + TabContent() { + Column() { + Text($r('app.string.queryAuthLockState')) + .width('70%') + .textAlign(TextAlign.Center) + .fontSize($r('app.float.size_20')) + Button($r('app.string.query')) + .onClick(() => { + this.obtainingAuthLockState().then((result : string) => { + this.authLockStateContent = result; + }) + }) + Text(this.authLockStateContent) + .fontSize($r('app.float.size_40')) + .textAlign(TextAlign.Center) + } + }.tabBar(this.tabBuilder($r('app.string.queryAuthLockStateTitle'), PageIndex.AUTH_LOCK_STATE_QUERIES, 'queryAuthLockState')) } .vertical(false) .barMode(BarMode.Fixed) diff --git a/UserAuthentication/entry/src/main/ets/pages/testPage.ets b/UserAuthentication/entry/src/main/ets/pages/testPage.ets index 121b3a584a712d84e404cde04311d5d61f158734..8b9856935761fda3df67b198aa79a8df3b3c1289 100644 --- a/UserAuthentication/entry/src/main/ets/pages/testPage.ets +++ b/UserAuthentication/entry/src/main/ets/pages/testPage.ets @@ -437,6 +437,27 @@ function obtainingEnrolledCredentialInformation() { } } +/* + * obtain-enrolled-state-capabilities.md + * 以查询用户PIN码认证类型的认证冻结状态为例 + * */ +async function obtainingAuthLockState() : Promise { + try { + Logger.info(`get auth lock state start`); + const authLockState : userAuth.AuthLockState = await userAuth.getAuthLockState(userAuth.UserAuthType.PIN); + if (authLockState.lockoutDuration === userAuth.PERMANENT_LOCKOUT_DURATION) { + Logger.info('the authentication of given authType is permanent locked'); + } + const authLockStateContent : string = JSON.stringify(authLockState); + Logger.info(`get auth lock state success, authLockState is: ${authLockStateContent}`); + return authLockStateContent; + } catch (error) { + const errorMessage : string = `get auth lock state failed, err code is : ${error?.code}, err message is : ${error?.message}`; + Logger.error(errorMessage); + return errorMessage; + } +} + async function comprehensiveFeatures() { let reuseUnlockResult: userAuth.ReuseUnlockResult = { reuseMode: userAuth.ReuseMode.AUTH_TYPE_RELEVANT, @@ -478,7 +499,8 @@ enum PageIndex { EXAMPLE_TAB_3 = 3, // 实例3页面的索引值 EXAMPLE_TAB_4 = 4, // 实例4页面的索引值 CREDENTIAL_QUERIES = 5, // 能力查询页面的索引值 - SIMULATION_VALIDATION = 6 // 模拟认证页面的索引值 + SIMULATION_VALIDATION = 6, // 模拟认证页面的索引值 + AUTH_LOCK_STATE_QUERIES = 7, // 查询认证冻结状态页面的索引值 } enum TextIdIndex { @@ -500,6 +522,7 @@ struct Index { @State credentialDigest: string = ''; @State whetherSupport: Resource = $r('app.string.waitQuery'); @State credentialValue: string = ''; + @State authLockStateContent : string = ''; SPACE_GAP: number = 5; @Builder @@ -753,6 +776,24 @@ struct Index { } .tabBar(this.tabBuilder($r('app.string.simulationValidation'), PageIndex.SIMULATION_VALIDATION, 'simulationValidation')) + + TabContent() { + Column() { + Text($r('app.string.queryAuthLockState')) + .width('70%') + .textAlign(TextAlign.Center) + .fontSize($r('app.float.size_20')) + Button($r('app.string.query')) + .onClick(() => { + obtainingAuthLockState().then((result : string) => { + this.authLockStateContent = result; + }) + }) + Text(this.authLockStateContent) + .fontSize($r('app.float.size_40')) + .textAlign(TextAlign.Center) + } + }.tabBar(this.tabBuilder($r('app.string.queryAuthLockStateTitle'), PageIndex.AUTH_LOCK_STATE_QUERIES, 'queryAuthLockState')) } .vertical(false) .barMode(BarMode.Fixed) diff --git a/UserAuthentication/entry/src/main/resources/base/element/string.json b/UserAuthentication/entry/src/main/resources/base/element/string.json index 8b63d0ea9fe9d01224ffe2b56a2c6313f3faec8c..1b7dfbcc2b9a09b06918e2b06b9bd038354002b4 100644 --- a/UserAuthentication/entry/src/main/resources/base/element/string.json +++ b/UserAuthentication/entry/src/main/resources/base/element/string.json @@ -64,6 +64,14 @@ "name": "queryCredentials", "value": "Query the status of the user's registration credentials, and when the authentication method is disabled and then enabled, the query credentials will change again" }, + { + "name": "queryAuthLockState", + "value": "Retrieve the lock status of the specified authentication type, including current lock status, remaining retry attempts, and lockout duration" + }, + { + "name": "queryAuthLockStateTitle", + "value": "Query auth lock state" + }, { "name": "customLogin", "value": "Impersonate a custom login" diff --git a/UserAuthentication/entry/src/main/resources/zh_CN/element/string.json b/UserAuthentication/entry/src/main/resources/zh_CN/element/string.json index 3cf58f08a4ced6545b498eb7c7cd68d85976436f..a11b384468cb8ff59e0599059f0f63638a71a13f 100644 --- a/UserAuthentication/entry/src/main/resources/zh_CN/element/string.json +++ b/UserAuthentication/entry/src/main/resources/zh_CN/element/string.json @@ -64,6 +64,14 @@ "name": "queryCredentials", "value": "查询用户注册凭据的状态,当认证方式被关闭再开启后,再次查询凭据会变化" }, + { + "name": "queryAuthLockStateTitle", + "value": "查询认证冻结状态" + }, + { + "name": "queryAuthLockState", + "value": "查询认证冻结状态,包含了认证类型是否被锁定,未锁定时的剩余可尝试次数以及锁定时的冻结时间。" + }, { "name": "customLogin", "value": "模拟自定义登录" diff --git a/UserAuthentication/screenshots/example1.jpeg b/UserAuthentication/screenshots/example1.jpeg deleted file mode 100644 index 27155f76abedf3fbc505523ea7580c02791c3e25..0000000000000000000000000000000000000000 Binary files a/UserAuthentication/screenshots/example1.jpeg and /dev/null differ diff --git a/UserAuthentication/screenshots/example1.jpg b/UserAuthentication/screenshots/example1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..54d7119f4af201a21e9e5338d92c96901a523041 Binary files /dev/null and b/UserAuthentication/screenshots/example1.jpg differ diff --git a/UserAuthentication/screenshots/mockLogin.jpeg b/UserAuthentication/screenshots/mockLogin.jpeg deleted file mode 100644 index baf5322b0977ce641e70962272eddc7cd2e562e1..0000000000000000000000000000000000000000 Binary files a/UserAuthentication/screenshots/mockLogin.jpeg and /dev/null differ diff --git a/UserAuthentication/screenshots/mockLogin.jpg b/UserAuthentication/screenshots/mockLogin.jpg new file mode 100644 index 0000000000000000000000000000000000000000..de9a5e8c00156243353fe672015ffd9bc79d646d Binary files /dev/null and b/UserAuthentication/screenshots/mockLogin.jpg differ diff --git a/UserAuthentication/screenshots/query.jpeg b/UserAuthentication/screenshots/query.jpeg deleted file mode 100644 index f804373a9ad7463e9315e0eb2f9004091517844b..0000000000000000000000000000000000000000 Binary files a/UserAuthentication/screenshots/query.jpeg and /dev/null differ diff --git a/UserAuthentication/screenshots/query.jpg b/UserAuthentication/screenshots/query.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a2db50f9575c5fb1082758189f226b3e3ce8f198 Binary files /dev/null and b/UserAuthentication/screenshots/query.jpg differ