-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathupdateauth.js
More file actions
33 lines (27 loc) · 825 Bytes
/
updateauth.js
File metadata and controls
33 lines (27 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 更改账号权限
var FIBOS = require('./initClient.js');
var client = FIBOS();
// 替换 xxxxxaccount yyyyyaccount 为你的账号
const user = {
'account': 'xxxxxaccount'
};
async function getNewPermissions(accountName) {
const account = await client.getAccount(accountName);
const perms = JSON.parse(JSON.stringify(account.permissions));
return perms;
}
// 复制 源 账号的所有权限
const perms = await getNewPermissions('yyyyyaccount');
const updateAuthResult = await client.transaction(tr => {
for (const perm of perms) {
tr.updateauth({
account: user.account,
permission: perm.perm_name,
parent: perm.parent,
auth: perm.required_auth
}, {
authorization: `${user.account}@owner`
});
}
});
console.log('Success =>', JSON.stringify(updateAuthResult));