Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
492a8fc6
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
492a8fc6
编写于
2月 08, 2023
作者:
A
Annie_wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update docs
Signed-off-by:
N
Annie_wang
<
annie.wangli@huawei.com
>
上级
823a3c06
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
129 addition
and
17 deletion
+129
-17
en/application-dev/reference/apis/js-apis-osAccount.md
en/application-dev/reference/apis/js-apis-osAccount.md
+129
-17
未找到文件。
en/application-dev/reference/apis/js-apis-osAccount.md
浏览文件 @
492a8fc6
...
...
@@ -84,13 +84,13 @@ Activates an OS account. This API uses an asynchronous callback to return the re
try
{
accountManager
.
activateOsAccount
(
localId
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
"
activateOsAccount failed, error:
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`activateOsAccount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
log
(
"
activateOsAccount successfully
"
);
}
});
}
catch
(
err
)
{
console
.
log
(
"
activateOsAccount exception:
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`activateOsAccount failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
...
...
@@ -170,13 +170,13 @@ Checks whether multiple OS accounts are supported. This API uses an asynchronous
try
{
accountManager
.
checkMultiOsAccountEnabled
((
err
,
isEnabled
)
=>
{
if
(
err
)
{
console
.
log
(
"
checkMultiOsAccountEnabled failed, error:
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`checkMultiOsAccountEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
else
{
console
.
log
(
"
checkMultiOsAccountEnabled successfully, isEnabled:
"
+
isEnabled
);
}
});
}
catch
(
err
)
{
console
.
log
(
"
checkMultiOsAccountEnabled exception:
"
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`checkMultiOsAccountEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
...
...
@@ -208,10 +208,10 @@ Checks whether multiple OS accounts are supported. This API uses a promise to re
accountManager
.
checkMultiOsAccountEnabled
().
then
((
isEnabled
)
=>
{
console
.
log
(
'
checkMultiOsAccountEnabled successfully, isEnabled:
'
+
isEnabled
);
}).
catch
((
err
)
=>
{
console
.
log
(
'
checkMultiOsAccountEnabled failed, error:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`checkMultiOsAccountEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
}
catch
(
err
)
{
console
.
log
(
'
checkMultiOsAccountEnabled exception:
'
+
JSON
.
stringify
(
err
)
);
console
.
error
(
`checkMultiOsAccountEnabled failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
...
...
@@ -3604,7 +3604,7 @@ Obtains the type of the account to which the current process belongs. This API u
getDistributedVirtualDeviceId(callback: AsyncCallback
<
string
>
): void
Obtains the ID of th
e
distributed virtual device. This API uses an asynchronous callback to return the result.
Obtains the ID of th
is
distributed virtual device. This API uses an asynchronous callback to return the result.
> **NOTE**
>
...
...
@@ -3634,7 +3634,7 @@ Obtains the ID of the distributed virtual device. This API uses an asynchronous
getDistributedVirtualDeviceId(): Promise
<
string
>
Obtains the ID of th
e
distributed virtual device. This API uses a promise to return the result.
Obtains the ID of th
is
distributed virtual device. This API uses a promise to return the result.
> **NOTE**
>
...
...
@@ -4323,13 +4323,13 @@ Unregisters this PIN inputer.
pinAuth
.
unregisterInputer
();
```
##
# InputerManager <sup>10
+</sup>
##
InputerManager <sup>9
+</sup>
Provides APIs for managing credential inputers.
### registerInputer<sup>
10
+</sup>
### registerInputer<sup>
9
+</sup>
registerInputer(authType: AuthType, inputer: IInputer): void;
static registerInputer(authType: AuthType, inputer: IInputer): void
Register a credential inputer.
...
...
@@ -4357,11 +4357,10 @@ Register a credential inputer.
**Example**
```
js
let
inputerMgr
=
new
account_osAccount
.
InputerManager
();
let
authType
=
account_osAccount
.
AuthType
.
DOMAIN
;
let
password
=
new
Uint8Array
([
0
,
0
,
0
,
0
,
0
]);
try
{
inputerMg
r
.
registerInputer
(
authType
,
{
account_osAccount
.
InputerManage
r
.
registerInputer
(
authType
,
{
onGetData
:
(
authSubType
,
callback
)
=>
{
callback
.
onSetData
(
authSubType
,
password
);
}
...
...
@@ -4372,9 +4371,9 @@ Register a credential inputer.
}
```
### unregisterInputer<sup>
10
+</sup>
### unregisterInputer<sup>
9
+</sup>
unregisterInputer(authType: AuthType): void;
static unregisterInputer(authType: AuthType): void
Unregisters this credential inputer.
...
...
@@ -4398,16 +4397,129 @@ Unregisters this credential inputer.
**Example**
```
js
let
inputerMgr
=
new
account_osAccount
.
InputerManager
();
let
authType
=
account_osAccount
.
AuthType
.
DOMAIN
;
try
{
inputerMg
r
.
unregisterInputer
(
authType
);
account_osAccount
.
InputerManage
r
.
unregisterInputer
(
authType
);
console
.
log
(
'
unregisterInputer success.
'
);
}
catch
(
err
)
{
console
.
log
(
"
unregisterInputer err:
"
+
JSON
.
stringify
(
err
));
}
```
## DomainPlugin<sup>9+</sup>
Provides APIs for domain account authentication.
**System API**
: This is a system API.
### auth<sup>9+</sup>
auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUserAuthCallback): void
Authenticates a domain account.
**System API**
: This is a system API.
**System capability**
: SystemCapability.Account.OsAccount
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | --------------- |
| domainAccountInfo |
[
DomainAccountInfo
](
#domainaccountinfo8
)
| Yes | Domain account information.|
| credential | Uint8Array | Yes | Credentials of the domain account.|
| callback |
[
IUserAuthCallback
](
#iuserauthcallback8
)
| Yes | Callback invoked to return the authentication result.|
**Example**
```
js
let
plugin
=
{
auth
:
(
domainInfo
,
credential
,
callback
)
=>
{
// mock authentication
callback
.
onResult
(
0
,
{});
}
}
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
);
let
userAuth
=
new
account_osAccount
.
UserAuth
();
let
challenge
=
new
Uint8Array
([
0
]);
let
authType
=
account_osAccount
.
AuthType
.
PIN
;
let
authTrustLevel
=
account_osAccount
.
AuthTrustLevel
.
ATL1
;
try
{
userAuth
.
auth
(
challenge
,
authType
,
authTrustLevel
,
{
onResult
:
(
resultCode
,
authResult
)
=>
{
console
.
log
(
'
auth resultCode =
'
+
resultCode
);
console
.
log
(
'
auth authResult =
'
+
JSON
.
stringify
(
authResult
));
}
});
}
catch
(
err
)
{
console
.
log
(
'
auth exception =
'
+
JSON
.
stringify
(
err
));
}
```
## DomainAccountManager <sup>9+</sup>
Provides APIs for domain account management.
### registerPlugin<sup>9+</sup>
static registerPlugin(plugin: DomainPlugin): void
Registers a domain plug-in.
**System API**
: This is a system API.
**System capability**
: SystemCapability.Account.OsAccount
**Required permissions**
: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**Parameters**
| Name | Type | Mandatory| Description |
| ----------| ----------------------- | --- | -------------------------- |
| plugin |
[
DomainPlugin
](
#domainplugin9
)
| Yes | Domain plug-in to register.|
**Error codes**
| ID| Error Message |
| -------- | --------------------------- |
| 12300201 | The domain plugin has been registered. |
**Example**
```
js
let
plugin
=
{
auth
:
(
domainInfo
,
credential
,
callback
)
=>
{
// mock authentication
callback
.
onResult
(
0
,
{});
}
}
try
{
account_osAccount
.
DomainAccountManager
.
registerPlugin
(
plugin
);
console
.
log
(
'
registerPlugin success.
'
);
}
catch
(
err
)
{
console
.
log
(
"
registerPlugin err:
"
+
JSON
.
stringify
(
err
));
}
```
### unregisterPlugin<sup>9+</sup>
static unregisterPlugin(): void
Unregisters this domain plug-in.
**System API**
: This is a system API.
**System capability**
: SystemCapability.Account.OsAccount
**Required permissions**
: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**Example**
```
js
try
{
account_osAccount
.
DomainAccountManager
.
unregisterPlugin
();
console
.
log
(
'
unregisterPlugin success.
'
);
}
catch
(
err
)
{
console
.
log
(
"
unregisterPlugin err:
"
+
JSON
.
stringify
(
err
));
}
```
## UserIdentityManager<sup>8+</sup>
Provides APIs for user identity management (IDM).
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录