propro-utils 1.5.53 → 1.5.56

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.
@@ -70,9 +70,9 @@ const getAccountProfile = async (redisClient, userSchema, accountId) => {
70
70
  */
71
71
  async function createUserGlobalStyles(userStyleSchema, accountId) {
72
72
  return await userStyleSchema.create({
73
- accountId,
74
73
  id: uuidv4(),
75
74
  styleShortcuts: defaultUserGlobalStyleShortcuts,
75
+ accountId,
76
76
  });
77
77
  }
78
78
 
@@ -110,13 +110,6 @@ async function createDefaultFolders(folderSchema, accountId) {
110
110
  */
111
111
  const checkIfUserExists = async accountId => {
112
112
  try {
113
- console.log('Checking if user exists:', accountId);
114
- console.log('defaultFolders', defaultFolders);
115
- console.log('defaultFolders.length', defaultFolders.length);
116
- console.log(
117
- 'defaultUserGlobalStyleShortcuts.length',
118
- defaultUserGlobalStyleShortcuts.length
119
- );
120
113
  const userSchema = await ServiceManager.getService('UserSchema');
121
114
  const userStyleSchema = await ServiceManager.getService('UserStyleSchema');
122
115
  const folderSchema = await ServiceManager.getService('FolderSchema');
@@ -137,7 +130,7 @@ const checkIfUserExists = async accountId => {
137
130
  await user.userGlobalStyles.save();
138
131
  }
139
132
  // Check if user has any folders
140
- const userFolders = await folderSchema.find({ user_id: accountId });
133
+ const userFolders = await folderSchema.find({ user_id: user.id });
141
134
  const defaultFolderNames = defaultFolders.map(folder => folder.name);
142
135
  const userFolderNames = userFolders.map(folder => folder.name);
143
136
 
@@ -150,18 +143,16 @@ const checkIfUserExists = async accountId => {
150
143
  foldersToCreate.map(folder =>
151
144
  folderSchema.create({
152
145
  ...folder,
153
- user_id: accountId,
146
+ user_id: user.id,
154
147
  })
155
148
  )
156
149
  );
157
150
  }
151
+
158
152
  return user;
159
153
  }
160
154
 
161
- const userGlobalStyles = await createUserGlobalStyles(
162
- userStyleSchema,
163
- accountId
164
- );
155
+ const userGlobalStyles = await createUserGlobalStyles(userStyleSchema);
165
156
 
166
157
  user = await userSchema.create({
167
158
  accountId,
@@ -170,7 +161,7 @@ const checkIfUserExists = async accountId => {
170
161
  userGlobalStyles: userGlobalStyles._id,
171
162
  });
172
163
 
173
- const folders = await createDefaultFolders(folderSchema, accountId);
164
+ const folders = await createDefaultFolders(folderSchema, user.id);
174
165
  console.log('Folders created:', folders);
175
166
  user.folders = folders.map(folder => folder._id);
176
167
  await user.save();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.5.53",
3
+ "version": "1.5.56",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {