propro-utils 1.5.46 → 1.5.49

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.
@@ -137,17 +137,19 @@ const checkIfUserExists = async accountId => {
137
137
  accountId
138
138
  );
139
139
 
140
- const folders = await createDefaultFolders(folderSchema, accountId);
141
- console.log('Folders created:', folders);
142
- user.folders = folders;
143
- await user.save();
144
-
145
- return await userSchema.create({
140
+ user = await userSchema.create({
146
141
  accountId,
147
142
  id: uuidv4(),
148
143
  verified: false,
149
144
  userGlobalStyles: userGlobalStyles._id,
150
145
  });
146
+
147
+ const folders = await createDefaultFolders(folderSchema, accountId);
148
+ console.log('Folders created:', folders);
149
+ user.folders = folders.map(folder => folder._id);
150
+ await user.save();
151
+
152
+ return user;
151
153
  } catch (error) {
152
154
  console.error('Error in checkIfUserExists:', error);
153
155
  throw new Error('Failed to get or create user');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.5.46",
3
+ "version": "1.5.49",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -50,10 +50,17 @@ let _serverAuth, _clientAuth;
50
50
  * ```
51
51
  */
52
52
  class ProProAuthMiddleware {
53
- constructor(options = {}, userSchema, userStyleSchema, redisClient) {
53
+ constructor(
54
+ options = {},
55
+ userSchema,
56
+ userStyleSchema,
57
+ folderSchema,
58
+ redisClient
59
+ ) {
54
60
  this.options = options;
55
61
  this.userSchema = userSchema;
56
62
  this.userStyleSchema = userStyleSchema;
63
+ this.folderSchema = folderSchema;
57
64
  this.redisClient = redisClient;
58
65
  this.serverAuth = null;
59
66
  this.clientAuth = null;
@@ -84,6 +91,7 @@ class ProProAuthMiddleware {
84
91
  this.options.serverOptions,
85
92
  this.userSchema,
86
93
  this.userStyleSchema,
94
+ this.folderSchema,
87
95
  this.redisClient
88
96
  );
89
97
  }
@@ -91,6 +99,7 @@ class ProProAuthMiddleware {
91
99
  ServiceManager.registerService('UserSchema', this.userSchema);
92
100
  ServiceManager.registerService('UserStyleSchema', this.userStyleSchema);
93
101
  ServiceManager.registerService('RedisClient', this.redisClient);
102
+ ServiceManager.registerService('FolderSchema', this.folderSchema);
94
103
  return this.serverAuth.middleware();
95
104
  }
96
105