propro-utils 1.5.78 → 1.5.80

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.
@@ -140,7 +140,10 @@ const checkIfUserExists = async accountId => {
140
140
  const user = await userSchema
141
141
  .findOne({ accountId })
142
142
  .populate('userGlobalStyles')
143
- .populate('theme')
143
+ .populate({
144
+ path: 'theme',
145
+ model: 'Theme',
146
+ })
144
147
  .lean();
145
148
 
146
149
  if (user) {
@@ -199,11 +202,12 @@ const checkIfUserExists = async accountId => {
199
202
  }
200
203
 
201
204
  // Handle themes
205
+ console.log('themeSchema:', themeSchema);
202
206
  if (themeSchema) {
203
207
  updates.push(
204
208
  (async () => {
205
209
  const defaultThemeExists = await themeSchema.exists({
206
- name: 'Default Theme',
210
+ // name: 'Default Theme',
207
211
  accountId,
208
212
  });
209
213
 
@@ -232,7 +236,10 @@ const checkIfUserExists = async accountId => {
232
236
  return userSchema
233
237
  .findOne({ accountId })
234
238
  .populate('userGlobalStyles')
235
- .populate('theme');
239
+ .populate({
240
+ path: 'theme',
241
+ model: 'Theme',
242
+ });
236
243
  }
237
244
 
238
245
  // Create new user with all associated data
@@ -262,6 +269,7 @@ const checkIfUserExists = async accountId => {
262
269
  id: uuidv4(),
263
270
  })
264
271
  .then(theme => {
272
+ console.log('Created theme:', theme);
265
273
  defaultTheme = theme;
266
274
  return theme;
267
275
  })
@@ -279,6 +287,7 @@ const checkIfUserExists = async accountId => {
279
287
  userGlobalStyles: userGlobalStyles?._id,
280
288
  theme: defaultTheme ? [defaultTheme._id] : undefined,
281
289
  });
290
+ console.log('Created user with theme:', newUser.theme);
282
291
 
283
292
  // Create folders if schema available
284
293
  if (folderSchema) {
@@ -289,7 +298,10 @@ const checkIfUserExists = async accountId => {
289
298
  return userSchema
290
299
  .findById(newUser._id)
291
300
  .populate('userGlobalStyles')
292
- .populate('theme');
301
+ .populate({
302
+ path: 'theme',
303
+ model: 'Theme',
304
+ });
293
305
  } catch (error) {
294
306
  console.error('Error in checkIfUserExists:', {
295
307
  accountId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.5.78",
3
+ "version": "1.5.80",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -157,7 +157,10 @@ class AuthMiddleware {
157
157
  this.options.redirectUri
158
158
  );
159
159
 
160
+ console.log('tokens:', tokens);
161
+ console.log('account:', account);
160
162
  const user = await checkIfUserExists(account.accountId);
163
+ console.log('user:', user);
161
164
 
162
165
  if (!user) {
163
166
  throw new Error('User not found');