diff --git a/zh-cn/application-dev/security/accesstoken-guidelines.md b/zh-cn/application-dev/security/accesstoken-guidelines.md index ff1b771dc8b721871b0b4886a1361ccb534b4374..c9a6502960194c4e74c142a123eaee03099f8c9d 100644 --- a/zh-cn/application-dev/security/accesstoken-guidelines.md +++ b/zh-cn/application-dev/security/accesstoken-guidelines.md @@ -148,11 +148,14 @@ atManager.requestPermissionsFromUser(context, permissions).then((data) => { console.info(`[requestPermissions] data: ${JSON.stringify(data)}`); let grantStatus: Array = data.authResults; - if (grantStatus[0] === -1) { - // 授权失败 - } else { - // 授权成功 + let length: number = grantStatus.length; + for (let i = 0; i < length; i++) { + if (grantStatus[i] !== 0) { + // 授权失败 + return; + } } + // 授权成功 }).catch((err) => { console.error(`[requestPermissions] Failed to start request permissions. Error: ${JSON.stringify(err)}`); }) @@ -178,11 +181,14 @@ atManager.requestPermissionsFromUser(context, permissions).then((data) => { console.info(`[requestPermissions] data: ${JSON.stringify(data)}`); let grantStatus: Array = data.authResults; - if (grantStatus[0] === -1) { - // 授权失败 - } else { - // 授权成功 + let length: number = grantStatus.length; + for (let i = 0; i < length; i++) { + if (grantStatus[i] !== 0) { + // 授权失败 + return; + } } + // 授权成功 }).catch((err) => { console.error(`[requestPermissions] Failed to start request permissions. Error: ${JSON.stringify(err)}`); })