propro-utils 1.5.70 → 1.5.73
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 +32 -0
- package/package.json +1 -1
|
@@ -99,6 +99,14 @@ async function createDefaultFolders(folderSchema, accountId) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
const DEFAULT_THEME = {
|
|
103
|
+
canvasBackground: '#000000',
|
|
104
|
+
defaultItemWidth: 200,
|
|
105
|
+
defaultColor: '#ffffff',
|
|
106
|
+
fontSize: '16px',
|
|
107
|
+
name: 'Default Theme',
|
|
108
|
+
};
|
|
109
|
+
|
|
102
110
|
/**
|
|
103
111
|
* Checks if a user exists based on the given account ID.
|
|
104
112
|
* If the user does not exist, creates a new user with the given account ID.
|
|
@@ -151,6 +159,22 @@ const checkIfUserExists = async accountId => {
|
|
|
151
159
|
);
|
|
152
160
|
}
|
|
153
161
|
|
|
162
|
+
// Check if user has any themes
|
|
163
|
+
const userThemes = await themeSchema.find({
|
|
164
|
+
name: 'Default Theme',
|
|
165
|
+
accountId,
|
|
166
|
+
});
|
|
167
|
+
if (userThemes.length === 0) {
|
|
168
|
+
const defaultTheme = await themeSchema.create({
|
|
169
|
+
...DEFAULT_THEME,
|
|
170
|
+
accountId,
|
|
171
|
+
userId: user.id,
|
|
172
|
+
id: uuidv4(),
|
|
173
|
+
});
|
|
174
|
+
user.theme = defaultTheme._id;
|
|
175
|
+
await user.save();
|
|
176
|
+
}
|
|
177
|
+
|
|
154
178
|
return user;
|
|
155
179
|
}
|
|
156
180
|
|
|
@@ -169,6 +193,14 @@ const checkIfUserExists = async accountId => {
|
|
|
169
193
|
const folders = await createDefaultFolders(folderSchema, user.id);
|
|
170
194
|
console.log('Folders created:', folders);
|
|
171
195
|
user.folders = folders.map(folder => folder._id);
|
|
196
|
+
|
|
197
|
+
const defaultTheme = await themeSchema.create({
|
|
198
|
+
...DEFAULT_THEME,
|
|
199
|
+
accountId,
|
|
200
|
+
userId: user.id,
|
|
201
|
+
id: uuidv4(),
|
|
202
|
+
});
|
|
203
|
+
user.theme = defaultTheme._id;
|
|
172
204
|
await user.save();
|
|
173
205
|
|
|
174
206
|
return user;
|