@firecms/user_management 3.0.0-canary.235 → 3.0.0-canary.237
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 +40 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +40 -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 +41 -0
- package/src/types/user_management.tsx +6 -0
package/dist/index.umd.js
CHANGED
@@ -254,6 +254,20 @@
|
|
254
254
|
if (!userExists) {
|
255
255
|
data.created_on = /* @__PURE__ */ new Date();
|
256
256
|
}
|
257
|
+
if (userExists && userExists.uid !== user.uid) {
|
258
|
+
const entity = {
|
259
|
+
values: {},
|
260
|
+
path: usersPath,
|
261
|
+
id: userExists.uid
|
262
|
+
};
|
263
|
+
await dataSourceDelegate.deleteEntity({
|
264
|
+
entity
|
265
|
+
}).then(() => {
|
266
|
+
console.debug("Deleted previous user", userExists);
|
267
|
+
}).catch((e_3) => {
|
268
|
+
console.error("Error deleting user", e_3);
|
269
|
+
});
|
270
|
+
}
|
257
271
|
return dataSourceDelegate.saveEntity({
|
258
272
|
status: "existing",
|
259
273
|
path: usersPath,
|
@@ -285,13 +299,13 @@
|
|
285
299
|
const {
|
286
300
|
uid
|
287
301
|
} = user_0;
|
288
|
-
const
|
302
|
+
const entity_0 = {
|
289
303
|
path: usersPath,
|
290
304
|
id: uid,
|
291
305
|
values: {}
|
292
306
|
};
|
293
307
|
await dataSourceDelegate.deleteEntity({
|
294
|
-
entity
|
308
|
+
entity: entity_0
|
295
309
|
});
|
296
310
|
}, [usersPath, dataSourceDelegate?.initialised]);
|
297
311
|
const deleteRole = React.useCallback(async (role_0) => {
|
@@ -301,13 +315,13 @@
|
|
301
315
|
const {
|
302
316
|
id: id_0
|
303
317
|
} = role_0;
|
304
|
-
const
|
318
|
+
const entity_1 = {
|
305
319
|
path: rolesPath,
|
306
320
|
id: id_0,
|
307
321
|
values: {}
|
308
322
|
};
|
309
323
|
await dataSourceDelegate.deleteEntity({
|
310
|
-
entity:
|
324
|
+
entity: entity_1
|
311
325
|
});
|
312
326
|
}, [rolesPath, dataSourceDelegate?.initialised]);
|
313
327
|
const collectionPermissions = React.useCallback(({
|
@@ -332,12 +346,27 @@
|
|
332
346
|
if (loading) {
|
333
347
|
return false;
|
334
348
|
}
|
349
|
+
if (user_3 === null) {
|
350
|
+
console.warn("User is null, returning");
|
351
|
+
return false;
|
352
|
+
}
|
335
353
|
if (users.length === 0) {
|
336
354
|
console.warn("No users created yet");
|
337
355
|
return true;
|
338
356
|
}
|
339
357
|
const mgmtUser_0 = users.find((u_3) => u_3.email?.toLowerCase() === user_3?.email?.toLowerCase());
|
340
358
|
if (mgmtUser_0) {
|
359
|
+
if (mgmtUser_0.uid !== user_3.uid) {
|
360
|
+
console.warn("User uid has changed, updating user in user management system");
|
361
|
+
saveUser({
|
362
|
+
...mgmtUser_0,
|
363
|
+
uid: user_3.uid
|
364
|
+
}).then(() => {
|
365
|
+
console.debug("User updated in user management system", mgmtUser_0);
|
366
|
+
}).catch((e_4) => {
|
367
|
+
console.error("Error updating user in user management system", e_4);
|
368
|
+
});
|
369
|
+
}
|
341
370
|
console.debug("User found in user management system", mgmtUser_0);
|
342
371
|
return true;
|
343
372
|
}
|
@@ -350,6 +379,12 @@
|
|
350
379
|
console.debug("Setting roles", userRoles);
|
351
380
|
authController.setUserRoles?.(userRoles ?? []);
|
352
381
|
}, [userRoleIds]);
|
382
|
+
const getUser = React.useCallback((uid_0) => {
|
383
|
+
if (!users) return null;
|
384
|
+
const user_4 = users.find((u_4) => u_4.uid === uid_0);
|
385
|
+
return user_4 ?? null;
|
386
|
+
}, [users]);
|
387
|
+
console.log("users", users);
|
353
388
|
return {
|
354
389
|
loading,
|
355
390
|
roles,
|
@@ -369,6 +404,7 @@
|
|
369
404
|
...authController,
|
370
405
|
initialLoading: authController.initialLoading || loading,
|
371
406
|
userRoles,
|
407
|
+
getUser,
|
372
408
|
user: authController.user ? {
|
373
409
|
...authController.user,
|
374
410
|
roles: userRoles
|