@abtnode/blocklet-services 1.16.15-beta-04d1e821 → 1.16.15-beta-e3a24907

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.
Files changed (2) hide show
  1. package/api/routes/user.js +37 -11
  2. package/package.json +18 -18
@@ -58,6 +58,12 @@ function checkUserEnable(user, { locale }) {
58
58
  }
59
59
  }
60
60
 
61
+ /**
62
+ * 组装用户 profile
63
+ * @param {{ avatar?: string, fullName: string, email: string}} profile
64
+ * @param {{node: any; req: any; teamDid: string; isCreate: boolean = false}} options
65
+ * @returns {Promise<{avatar: string, fullName: string, email: string}>}
66
+ */
61
67
  async function composeProfileData({ avatar, fullName, email }, { node, req, teamDid, isCreate = false }) {
62
68
  const profile = {};
63
69
  let avatarLocal;
@@ -89,7 +95,10 @@ async function composeProfileData({ avatar, fullName, email }, { node, req, team
89
95
  return profile;
90
96
  }
91
97
 
92
- async function loginWallet({ did, pk, avatar, email, fullName }, { node, req, locale, componentId, teamDid }) {
98
+ async function loginWallet(
99
+ { did, pk, avatar, email, fullName },
100
+ { node, req, locale, componentId, teamDid, updateInfo = true }
101
+ ) {
93
102
  const provider = LOGIN_PROVIDER.WALLET;
94
103
  const { error } = loginWalletSchema.validate({
95
104
  provider,
@@ -113,10 +122,12 @@ async function loginWallet({ did, pk, avatar, email, fullName }, { node, req, lo
113
122
  },
114
123
  });
115
124
 
116
- let profile;
125
+ let profile = {};
117
126
  if (currentUser) {
118
- await checkUserEnable(currentUser, { locale });
119
- profile = await composeProfileData({ avatar, email, fullName }, { node, req, teamDid });
127
+ if (updateInfo) {
128
+ await checkUserEnable(currentUser, { locale });
129
+ profile = await composeProfileData({ avatar, email, fullName }, { node, req, teamDid });
130
+ }
120
131
  } else {
121
132
  await checkNeedInvite({ req, node, teamDid, componentId, locale });
122
133
  profile = await composeProfileData({ avatar, email, fullName }, { node, req, teamDid, isCreate: true });
@@ -145,7 +156,7 @@ async function loginWallet({ did, pk, avatar, email, fullName }, { node, req, lo
145
156
 
146
157
  async function loginOAuth(
147
158
  { provider, id, avatar, email, fullName },
148
- { node, req, locale, componentId, teamDid, blockletWallet }
159
+ { node, req, locale, componentId, teamDid, blockletWallet, updateInfo = true }
149
160
  ) {
150
161
  const { error } = loginOAuthSchema.validate({
151
162
  provider,
@@ -171,10 +182,12 @@ async function loginOAuth(
171
182
  },
172
183
  });
173
184
 
174
- let profile;
185
+ let profile = {};
175
186
  if (currentUser) {
176
- await checkUserEnable(currentUser, { locale });
177
- profile = await composeProfileData({ avatar, email, fullName }, { node, req, teamDid });
187
+ if (updateInfo) {
188
+ await checkUserEnable(currentUser, { locale });
189
+ profile = await composeProfileData({ avatar, email, fullName }, { node, req, teamDid });
190
+ }
178
191
  } else {
179
192
  await checkNeedInvite({ req, node, teamDid, componentId, locale });
180
193
  profile = await composeProfileData({ avatar, email, fullName }, { node, req, teamDid, isCreate: true });
@@ -201,7 +214,17 @@ async function loginOAuth(
201
214
  }
202
215
 
203
216
  async function login(req, node, options) {
204
- const { provider = LOGIN_PROVIDER.WALLET, did, pk, avatar, email, fullName, id, locale = 'en' } = req.body;
217
+ const {
218
+ provider = LOGIN_PROVIDER.WALLET,
219
+ did,
220
+ pk,
221
+ avatar,
222
+ email,
223
+ fullName,
224
+ id,
225
+ locale = 'en',
226
+ updateInfo = true,
227
+ } = req.body;
205
228
 
206
229
  const componentId = req.get('x-blocklet-component-id');
207
230
  if (!componentId) {
@@ -212,11 +235,14 @@ async function login(req, node, options) {
212
235
 
213
236
  let doc;
214
237
  if (provider === LOGIN_PROVIDER.WALLET) {
215
- doc = await loginWallet({ did, pk, avatar, email, fullName }, { node, req, locale, componentId, teamDid });
238
+ doc = await loginWallet(
239
+ { did, pk, avatar, email, fullName },
240
+ { node, req, locale, componentId, teamDid, updateInfo }
241
+ );
216
242
  } else {
217
243
  doc = await loginOAuth(
218
244
  { provider, id, avatar, email, fullName },
219
- { node, req, locale, componentId, teamDid, blockletWallet }
245
+ { node, req, locale, componentId, teamDid, blockletWallet, updateInfo }
220
246
  );
221
247
  }
222
248
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.15-beta-04d1e821",
6
+ "version": "1.16.15-beta-e3a24907",
7
7
  "description": "Provide unified services for every blocklet",
8
8
  "main": "api/index.js",
9
9
  "files": [
@@ -33,17 +33,17 @@
33
33
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
34
34
  "license": "Apache-2.0",
35
35
  "dependencies": {
36
- "@abtnode/analytics": "1.16.15-beta-04d1e821",
37
- "@abtnode/auth": "1.16.15-beta-04d1e821",
38
- "@abtnode/client": "1.16.15-beta-04d1e821",
39
- "@abtnode/connect-storage": "1.16.15-beta-04d1e821",
40
- "@abtnode/constant": "1.16.15-beta-04d1e821",
41
- "@abtnode/core": "1.16.15-beta-04d1e821",
42
- "@abtnode/cron": "1.16.15-beta-04d1e821",
43
- "@abtnode/logger": "1.16.15-beta-04d1e821",
44
- "@abtnode/models": "1.16.15-beta-04d1e821",
45
- "@abtnode/router-templates": "1.16.15-beta-04d1e821",
46
- "@abtnode/util": "1.16.15-beta-04d1e821",
36
+ "@abtnode/analytics": "1.16.15-beta-e3a24907",
37
+ "@abtnode/auth": "1.16.15-beta-e3a24907",
38
+ "@abtnode/client": "1.16.15-beta-e3a24907",
39
+ "@abtnode/connect-storage": "1.16.15-beta-e3a24907",
40
+ "@abtnode/constant": "1.16.15-beta-e3a24907",
41
+ "@abtnode/core": "1.16.15-beta-e3a24907",
42
+ "@abtnode/cron": "1.16.15-beta-e3a24907",
43
+ "@abtnode/logger": "1.16.15-beta-e3a24907",
44
+ "@abtnode/models": "1.16.15-beta-e3a24907",
45
+ "@abtnode/router-templates": "1.16.15-beta-e3a24907",
46
+ "@abtnode/util": "1.16.15-beta-e3a24907",
47
47
  "@arcblock/did": "^1.18.89",
48
48
  "@arcblock/did-auth": "1.18.89",
49
49
  "@arcblock/did-ext": "^1.18.89",
@@ -52,11 +52,11 @@
52
52
  "@arcblock/jwt": "1.18.89",
53
53
  "@arcblock/validator": "^1.18.89",
54
54
  "@arcblock/ws": "1.18.89",
55
- "@blocklet/constant": "1.16.15-beta-04d1e821",
55
+ "@blocklet/constant": "1.16.15-beta-e3a24907",
56
56
  "@blocklet/form-builder": "^0.1.11",
57
57
  "@blocklet/form-collector": "^0.1.6",
58
- "@blocklet/meta": "1.16.15-beta-04d1e821",
59
- "@blocklet/sdk": "1.16.15-beta-04d1e821",
58
+ "@blocklet/meta": "1.16.15-beta-e3a24907",
59
+ "@blocklet/sdk": "1.16.15-beta-e3a24907",
60
60
  "@did-connect/authenticator": "^2.2.0",
61
61
  "@did-connect/relay-adapter-express": "^2.2.0",
62
62
  "@did-connect/storage-nedb": "^2.2.0",
@@ -94,12 +94,12 @@
94
94
  "@nedb/core": "^2.1.2"
95
95
  },
96
96
  "devDependencies": {
97
- "@abtnode/ux": "1.16.15-beta-04d1e821",
97
+ "@abtnode/ux": "1.16.15-beta-e3a24907",
98
98
  "@arcblock/did-connect": "^2.7.6",
99
99
  "@arcblock/icons": "^2.7.6",
100
100
  "@arcblock/ux": "^2.7.6",
101
101
  "@blocklet/launcher-layout": "2.1.93",
102
- "@blocklet/tracker": "1.16.15-beta-04d1e821",
102
+ "@blocklet/tracker": "1.16.15-beta-e3a24907",
103
103
  "@blocklet/ui-react": "^2.7.6",
104
104
  "@emotion/react": "^11.10.4",
105
105
  "@emotion/styled": "^11.10.4",
@@ -169,5 +169,5 @@
169
169
  "url": "https://github.com/ArcBlock/blocklet-server/issues",
170
170
  "email": "shijun@arcblock.io"
171
171
  },
172
- "gitHead": "42e1523e5b92a3a57d9083ae29455df429afb0f6"
172
+ "gitHead": "b87c810902571b8cdb8f12ef497286b1549888e9"
173
173
  }