@firecms/user_management 3.0.0-canary.235 → 3.0.0-canary.239
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/dist/index.es.js +39 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +39 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/types/user_management.d.ts +5 -0
- package/package.json +5 -5
- package/src/hooks/useBuildUserManagement.tsx +40 -0
- package/src/types/user_management.tsx +6 -0
package/dist/index.es.js
CHANGED
@@ -242,6 +242,20 @@ function useBuildUserManagement({
|
|
242
242
|
if (!userExists) {
|
243
243
|
data.created_on = /* @__PURE__ */ new Date();
|
244
244
|
}
|
245
|
+
if (userExists && userExists.uid !== user.uid) {
|
246
|
+
const entity = {
|
247
|
+
values: {},
|
248
|
+
path: usersPath,
|
249
|
+
id: userExists.uid
|
250
|
+
};
|
251
|
+
await dataSourceDelegate.deleteEntity({
|
252
|
+
entity
|
253
|
+
}).then(() => {
|
254
|
+
console.debug("Deleted previous user", userExists);
|
255
|
+
}).catch((e_3) => {
|
256
|
+
console.error("Error deleting user", e_3);
|
257
|
+
});
|
258
|
+
}
|
245
259
|
return dataSourceDelegate.saveEntity({
|
246
260
|
status: "existing",
|
247
261
|
path: usersPath,
|
@@ -273,13 +287,13 @@ function useBuildUserManagement({
|
|
273
287
|
const {
|
274
288
|
uid
|
275
289
|
} = user_0;
|
276
|
-
const
|
290
|
+
const entity_0 = {
|
277
291
|
path: usersPath,
|
278
292
|
id: uid,
|
279
293
|
values: {}
|
280
294
|
};
|
281
295
|
await dataSourceDelegate.deleteEntity({
|
282
|
-
entity
|
296
|
+
entity: entity_0
|
283
297
|
});
|
284
298
|
}, [usersPath, dataSourceDelegate?.initialised]);
|
285
299
|
const deleteRole = useCallback(async (role_0) => {
|
@@ -289,13 +303,13 @@ function useBuildUserManagement({
|
|
289
303
|
const {
|
290
304
|
id: id_0
|
291
305
|
} = role_0;
|
292
|
-
const
|
306
|
+
const entity_1 = {
|
293
307
|
path: rolesPath,
|
294
308
|
id: id_0,
|
295
309
|
values: {}
|
296
310
|
};
|
297
311
|
await dataSourceDelegate.deleteEntity({
|
298
|
-
entity:
|
312
|
+
entity: entity_1
|
299
313
|
});
|
300
314
|
}, [rolesPath, dataSourceDelegate?.initialised]);
|
301
315
|
const collectionPermissions = useCallback(({
|
@@ -320,12 +334,27 @@ function useBuildUserManagement({
|
|
320
334
|
if (loading) {
|
321
335
|
return false;
|
322
336
|
}
|
337
|
+
if (user_3 === null) {
|
338
|
+
console.warn("User is null, returning");
|
339
|
+
return false;
|
340
|
+
}
|
323
341
|
if (users.length === 0) {
|
324
342
|
console.warn("No users created yet");
|
325
343
|
return true;
|
326
344
|
}
|
327
345
|
const mgmtUser_0 = users.find((u_3) => u_3.email?.toLowerCase() === user_3?.email?.toLowerCase());
|
328
346
|
if (mgmtUser_0) {
|
347
|
+
if (mgmtUser_0.uid !== user_3.uid) {
|
348
|
+
console.warn("User uid has changed, updating user in user management system");
|
349
|
+
saveUser({
|
350
|
+
...mgmtUser_0,
|
351
|
+
uid: user_3.uid
|
352
|
+
}).then(() => {
|
353
|
+
console.debug("User updated in user management system", mgmtUser_0);
|
354
|
+
}).catch((e_4) => {
|
355
|
+
console.error("Error updating user in user management system", e_4);
|
356
|
+
});
|
357
|
+
}
|
329
358
|
console.debug("User found in user management system", mgmtUser_0);
|
330
359
|
return true;
|
331
360
|
}
|
@@ -338,6 +367,11 @@ function useBuildUserManagement({
|
|
338
367
|
console.debug("Setting roles", userRoles);
|
339
368
|
authController.setUserRoles?.(userRoles ?? []);
|
340
369
|
}, [userRoleIds]);
|
370
|
+
const getUser = useCallback((uid_0) => {
|
371
|
+
if (!users) return null;
|
372
|
+
const user_4 = users.find((u_4) => u_4.uid === uid_0);
|
373
|
+
return user_4 ?? null;
|
374
|
+
}, [users]);
|
341
375
|
return {
|
342
376
|
loading,
|
343
377
|
roles,
|
@@ -357,6 +391,7 @@ function useBuildUserManagement({
|
|
357
391
|
...authController,
|
358
392
|
initialLoading: authController.initialLoading || loading,
|
359
393
|
userRoles,
|
394
|
+
getUser,
|
360
395
|
user: authController.user ? {
|
361
396
|
...authController.user,
|
362
397
|
roles: userRoles
|