提交 b643cb08 编写于 作者: J jidong

modify demo code error

Signed-off-by: Njidong <jidong4@huawei.com>
上级 f2bb5b07
...@@ -1366,15 +1366,17 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic ...@@ -1366,15 +1366,17 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant((err, want) => { featureAbility.getWant((err, want) => {
var sessionId = want.parameters[Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => { appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => {
if (err.code != ResultCode.SUCCESS) { if (err.code != account_appAccount.ResultCode.SUCCESS) {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
return; return;
} }
var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
callback.OnResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
}); });
}); });
``` ```
...@@ -1402,11 +1404,13 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt ...@@ -1402,11 +1404,13 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt
``` ```
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
featureAbility.getWant().then((want) => { featureAbility.getWant().then((want) => {
var sessionId = want.parameters[Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
callback.OnResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -1561,9 +1565,11 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void; ...@@ -1561,9 +1565,11 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void;
const appAccountManager = account_appAccount.createAppAccountManager(); const appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = "1234";
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi",
Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; [account_appAccount.Constants.KEY_OWNER]: "com.example.ohos.accountjsdemo",
callback.OnResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: "readAge",
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.OnResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
}); });
...@@ -1592,8 +1598,10 @@ onRequestRedirected: (request: Want) =&gt; void; ...@@ -1592,8 +1598,10 @@ onRequestRedirected: (request: Want) =&gt; void;
} }
authenticate(name, authType, callerBundleName, options, callback) { authenticate(name, authType, callerBundleName, options, callback) {
var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"}; var result = {[account_appAccount.Constants.KEY_NAME]: name,
callback.onResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
} }
``` ```
...@@ -1643,8 +1651,10 @@ authenticate(name: string, authType: string, callerBundleName: string, options: ...@@ -1643,8 +1651,10 @@ authenticate(name: string, authType: string, callerBundleName: string, options:
} }
authenticate(name, authType, callerBundleName, options, callback) { authenticate(name, authType, callerBundleName, options, callback) {
var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"}; var result = {[account_appAccount.Constants.KEY_NAME]: name,
callback.onResult(ResultCode.SUCCESS, result); [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
} }
......
...@@ -387,7 +387,7 @@ removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -387,7 +387,7 @@ removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
var createIocalId; var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
createIocalId = osAccountInfo.localId; createIocalId = osAccountInfo.localId;
)}; });
accountManager.removeOsAccount(createIocalId, (err)=>{ accountManager.removeOsAccount(createIocalId, (err)=>{
console.log("removeOsAccount err:" + JSON.stringify(err)); console.log("removeOsAccount err:" + JSON.stringify(err));
}); });
...@@ -418,7 +418,7 @@ removeOsAccount(localId: number): Promise&lt;void&gt; ...@@ -418,7 +418,7 @@ removeOsAccount(localId: number): Promise&lt;void&gt;
var createIocalId; var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
createIocalId = osAccountInfo.localId; createIocalId = osAccountInfo.localId;
)}; });
createIocalId = osAccount.localId; createIocalId = osAccount.localId;
accountManager.removeOsAccount(createIocalId).then(() => { accountManager.removeOsAccount(createIocalId).then(() => {
console.log('removeOsAccount Success'); console.log('removeOsAccount Success');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册