propro-utils 1.5.85 → 1.5.86
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/middlewares/account_info.js +11 -20
- package/package.json +1 -1
|
@@ -139,11 +139,7 @@ const checkIfUserExists = async accountId => {
|
|
|
139
139
|
// Find existing user with populated fields
|
|
140
140
|
const user = await userSchema
|
|
141
141
|
.findOne({ accountId })
|
|
142
|
-
.
|
|
143
|
-
.populate({
|
|
144
|
-
path: 'theme',
|
|
145
|
-
model: 'Theme',
|
|
146
|
-
})
|
|
142
|
+
.select('-theme -folderList -userGlobalStyles -mapList')
|
|
147
143
|
.lean();
|
|
148
144
|
|
|
149
145
|
if (user) {
|
|
@@ -231,13 +227,11 @@ const checkIfUserExists = async accountId => {
|
|
|
231
227
|
// Wait for all updates to complete
|
|
232
228
|
await Promise.all(updates);
|
|
233
229
|
|
|
234
|
-
// Return fresh user data after updates
|
|
235
|
-
return userSchema
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// model: 'Theme',
|
|
240
|
-
// });
|
|
230
|
+
// Return fresh user data after updates, excluding specified fields
|
|
231
|
+
return userSchema
|
|
232
|
+
.findOne({ accountId })
|
|
233
|
+
.select('-theme -folderList -userGlobalStyles -mapList')
|
|
234
|
+
.lean();
|
|
241
235
|
}
|
|
242
236
|
|
|
243
237
|
// Create new user with all associated data
|
|
@@ -285,20 +279,17 @@ const checkIfUserExists = async accountId => {
|
|
|
285
279
|
userGlobalStyles: userGlobalStyles?._id,
|
|
286
280
|
theme: defaultTheme ? [defaultTheme._id] : undefined,
|
|
287
281
|
});
|
|
288
|
-
console.log('Created user with theme:', newUser.theme);
|
|
289
282
|
|
|
290
283
|
// Create folders if schema available
|
|
291
284
|
if (folderSchema) {
|
|
292
285
|
await createDefaultFolders(folderSchema, newUser.id);
|
|
293
286
|
}
|
|
294
287
|
|
|
295
|
-
// Return
|
|
296
|
-
return userSchema
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
// model: 'Theme',
|
|
301
|
-
// });
|
|
288
|
+
// Return user object excluding specified fields
|
|
289
|
+
return userSchema
|
|
290
|
+
.findById(newUser._id)
|
|
291
|
+
.select('-theme -folderList -userGlobalStyles -mapList')
|
|
292
|
+
.lean();
|
|
302
293
|
} catch (error) {
|
|
303
294
|
console.error('Error in checkIfUserExists:', {
|
|
304
295
|
accountId,
|