@abtnode/util 1.16.26-beta-818ea1c5 → 1.16.26-beta-351de484
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/user.js +10 -1
- package/package.json +6 -6
package/lib/user.js
CHANGED
|
@@ -141,6 +141,12 @@ const parseUserAvatar = async (avatar, { dataDir } = {}) => {
|
|
|
141
141
|
return data;
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* 更新关联的第三方账户
|
|
146
|
+
* @param {import('@abtnode/types').TConnectedAccount[]} connectedAccounts
|
|
147
|
+
* @param {import('@abtnode/types').TConnectedAccount} connectedAccount
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
144
150
|
function updateConnectedAccount(connectedAccounts = [], connectedAccount = {}) {
|
|
145
151
|
const now = new Date().toISOString();
|
|
146
152
|
const accounts = connectedAccounts.filter(Boolean);
|
|
@@ -148,13 +154,16 @@ function updateConnectedAccount(connectedAccounts = [], connectedAccount = {}) {
|
|
|
148
154
|
const updates = Array.isArray(connectedAccount) ? connectedAccount : [connectedAccount];
|
|
149
155
|
updates.filter(Boolean).forEach((x) => {
|
|
150
156
|
if (x.provider && x.did) {
|
|
151
|
-
|
|
157
|
+
// 在插入 connectedAccount 表时,会根据 did 字段来插入,所以只需要判断 did 相等即可,不再需要判断 provider 是否一致
|
|
158
|
+
const index = updated.findIndex((item) => item.did === x.did);
|
|
152
159
|
if (index > -1) {
|
|
153
160
|
updated[index] = {
|
|
154
161
|
...accounts[index],
|
|
155
162
|
...x,
|
|
156
163
|
lastLoginAt: now,
|
|
157
164
|
};
|
|
165
|
+
// HACK: 关联账户的 provider 不允许被变更,将它还原为原有的值
|
|
166
|
+
updated[index].provider = accounts[index].provider || x.provider;
|
|
158
167
|
} else {
|
|
159
168
|
updated.push({
|
|
160
169
|
firstLoginAt: now,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.26-beta-
|
|
6
|
+
"version": "1.16.26-beta-351de484",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.26-beta-
|
|
22
|
-
"@abtnode/logger": "1.16.26-beta-
|
|
23
|
-
"@blocklet/constant": "1.16.26-beta-
|
|
24
|
-
"@blocklet/meta": "1.16.26-beta-
|
|
21
|
+
"@abtnode/constant": "1.16.26-beta-351de484",
|
|
22
|
+
"@abtnode/logger": "1.16.26-beta-351de484",
|
|
23
|
+
"@blocklet/constant": "1.16.26-beta-351de484",
|
|
24
|
+
"@blocklet/meta": "1.16.26-beta-351de484",
|
|
25
25
|
"@ocap/client": "1.18.115",
|
|
26
26
|
"@ocap/mcrypto": "1.18.115",
|
|
27
27
|
"@ocap/util": "1.18.115",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"fs-extra": "^11.2.0",
|
|
77
77
|
"jest": "^29.7.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "00eba435a21506382c7823ea804abea196390a0f"
|
|
80
80
|
}
|