propro-utils 1.5.36 → 1.5.38

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.
@@ -85,7 +85,10 @@ const checkIfUserExists = async accountId => {
85
85
  try {
86
86
  const userSchema = await ServiceManager.getService('UserSchema');
87
87
  const userStyleSchema = await ServiceManager.getService('UserStyleSchema');
88
- let user = await userSchema.findOne({ accountId });
88
+
89
+ let user = await userSchema
90
+ .findOne({ accountId })
91
+ .populate('userGlobalStyles');
89
92
 
90
93
  if (user) {
91
94
  if (!user.userGlobalStyles) {
@@ -102,16 +105,17 @@ const checkIfUserExists = async accountId => {
102
105
  userStyleSchema,
103
106
  accountId
104
107
  );
108
+
105
109
  user = await userSchema.create({
106
110
  accountId,
107
111
  id: uuidv4(),
108
112
  verified: false,
109
- userGlobalStyles,
113
+ userGlobalStyles: userGlobalStyles._id,
110
114
  });
111
115
 
112
116
  return user;
113
117
  } catch (error) {
114
- console.error('Error in getOrCreateUser:', error);
118
+ console.error('Error in checkIfUserExists:', error);
115
119
  throw new Error('Failed to get or create user');
116
120
  }
117
121
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.5.36",
3
+ "version": "1.5.38",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -44,6 +44,7 @@ const sanitizeUser = user => {
44
44
  sanitized.accountId = sanitized._doc.accountId;
45
45
  sanitized.createdAt = sanitized._doc.createdAt;
46
46
  sanitized.updatedAt = sanitized._doc.updatedAt;
47
+ sanitized.userGlobalStyles = sanitized._doc.userGlobalStyles;
47
48
 
48
49
  delete sanitized._doc.mapList;
49
50
  delete sanitized._doc.folderList;