@firecms/user_management 3.0.0-beta.13 → 3.0.0-beta.15

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.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 entity = {
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 entity_0 = {
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: entity_0
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,11 @@
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]);
353
387
  return {
354
388
  loading,
355
389
  roles,
@@ -369,6 +403,7 @@
369
403
  ...authController,
370
404
  initialLoading: authController.initialLoading || loading,
371
405
  userRoles,
406
+ getUser,
372
407
  user: authController.user ? {
373
408
  ...authController.user,
374
409
  roles: userRoles
@@ -465,7 +500,7 @@
465
500
  return true;
466
501
  }
467
502
  function RolesDetailsForm(t0) {
468
- const $ = reactCompilerRuntime.c(165);
503
+ const $ = reactCompilerRuntime.c(164);
469
504
  const {
470
505
  open,
471
506
  role,
@@ -1080,7 +1115,7 @@
1080
1115
  }
1081
1116
  let t80;
1082
1117
  if ($[144] !== handleClose) {
1083
- t80 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", onClick: () => {
1118
+ t80 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", color: "primary", onClick: () => {
1084
1119
  handleClose();
1085
1120
  }, children: "Cancel" });
1086
1121
  $[144] = handleClose;
@@ -1089,71 +1124,64 @@
1089
1124
  t80 = $[145];
1090
1125
  }
1091
1126
  const t81 = !dirty;
1092
- let t82;
1093
- if ($[146] === Symbol.for("react.memo_cache_sentinel")) {
1094
- t82 = /* @__PURE__ */ jsxRuntime.jsx(ui.CheckIcon, {});
1095
- $[146] = t82;
1096
- } else {
1097
- t82 = $[146];
1098
- }
1099
- const t83 = isNewRole ? "Create role" : "Update";
1100
- let t84;
1101
- if ($[147] !== isSubmitting || $[148] !== t81 || $[149] !== t83) {
1102
- t84 = /* @__PURE__ */ jsxRuntime.jsx(ui.LoadingButton, { variant: "filled", color: "primary", type: "submit", disabled: t81, loading: isSubmitting, startIcon: t82, children: t83 });
1103
- $[147] = isSubmitting;
1104
- $[148] = t81;
1127
+ const t82 = isNewRole ? "Create role" : "Update";
1128
+ let t83;
1129
+ if ($[146] !== isSubmitting || $[147] !== t81 || $[148] !== t82) {
1130
+ t83 = /* @__PURE__ */ jsxRuntime.jsx(ui.LoadingButton, { variant: "filled", color: "primary", type: "submit", disabled: t81, loading: isSubmitting, children: t82 });
1131
+ $[146] = isSubmitting;
1132
+ $[147] = t81;
1133
+ $[148] = t82;
1105
1134
  $[149] = t83;
1106
- $[150] = t84;
1107
1135
  } else {
1108
- t84 = $[150];
1136
+ t83 = $[149];
1109
1137
  }
1110
- let t85;
1111
- if ($[151] !== t79 || $[152] !== t80 || $[153] !== t84) {
1112
- t85 = /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogActions, { position: "sticky", children: [
1138
+ let t84;
1139
+ if ($[150] !== t79 || $[151] !== t80 || $[152] !== t83) {
1140
+ t84 = /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogActions, { position: "sticky", children: [
1113
1141
  t79,
1114
1142
  t80,
1115
- t84
1143
+ t83
1116
1144
  ] });
1117
- $[151] = t79;
1118
- $[152] = t80;
1145
+ $[150] = t79;
1146
+ $[151] = t80;
1147
+ $[152] = t83;
1119
1148
  $[153] = t84;
1120
- $[154] = t85;
1121
1149
  } else {
1122
- t85 = $[154];
1150
+ t84 = $[153];
1123
1151
  }
1124
- let t86;
1125
- if ($[155] !== formex$1.handleSubmit || $[156] !== t78 || $[157] !== t85) {
1126
- t86 = /* @__PURE__ */ jsxRuntime.jsxs("form", { noValidate: true, autoComplete: "off", onSubmit: formex$1.handleSubmit, style: t7, children: [
1152
+ let t85;
1153
+ if ($[154] !== formex$1.handleSubmit || $[155] !== t78 || $[156] !== t84) {
1154
+ t85 = /* @__PURE__ */ jsxRuntime.jsxs("form", { noValidate: true, autoComplete: "off", onSubmit: formex$1.handleSubmit, style: t7, children: [
1127
1155
  t8,
1128
1156
  t78,
1129
- t85
1157
+ t84
1130
1158
  ] });
1131
- $[155] = formex$1.handleSubmit;
1132
- $[156] = t78;
1159
+ $[154] = formex$1.handleSubmit;
1160
+ $[155] = t78;
1161
+ $[156] = t84;
1133
1162
  $[157] = t85;
1134
- $[158] = t86;
1135
1163
  } else {
1136
- t86 = $[158];
1164
+ t85 = $[157];
1137
1165
  }
1138
- let t87;
1139
- if ($[159] !== formex$1 || $[160] !== t86) {
1140
- t87 = /* @__PURE__ */ jsxRuntime.jsx(formex.Formex, { value: formex$1, children: t86 });
1141
- $[159] = formex$1;
1166
+ let t86;
1167
+ if ($[158] !== formex$1 || $[159] !== t85) {
1168
+ t86 = /* @__PURE__ */ jsxRuntime.jsx(formex.Formex, { value: formex$1, children: t85 });
1169
+ $[158] = formex$1;
1170
+ $[159] = t85;
1142
1171
  $[160] = t86;
1143
- $[161] = t87;
1144
1172
  } else {
1145
- t87 = $[161];
1173
+ t86 = $[160];
1146
1174
  }
1147
- let t88;
1148
- if ($[162] !== open || $[163] !== t87) {
1149
- t88 = /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open, maxWidth: "4xl", children: t87 });
1150
- $[162] = open;
1175
+ let t87;
1176
+ if ($[161] !== open || $[162] !== t86) {
1177
+ t87 = /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open, maxWidth: "4xl", children: t86 });
1178
+ $[161] = open;
1179
+ $[162] = t86;
1151
1180
  $[163] = t87;
1152
- $[164] = t88;
1153
1181
  } else {
1154
- t88 = $[164];
1182
+ t87 = $[163];
1155
1183
  }
1156
- return t88;
1184
+ return t87;
1157
1185
  }
1158
1186
  function _temp6$1(value_1) {
1159
1187
  return value_1 === "own" ? "Own" : value_1 === "true" ? "Yes" : "No";
@@ -1460,7 +1488,7 @@
1460
1488
  return true;
1461
1489
  }
1462
1490
  function UserDetailsForm(t0) {
1463
- const $ = reactCompilerRuntime.c(74);
1491
+ const $ = reactCompilerRuntime.c(73);
1464
1492
  const {
1465
1493
  open,
1466
1494
  user: userProp,
@@ -1698,7 +1726,7 @@
1698
1726
  }
1699
1727
  let t25;
1700
1728
  if ($[53] !== handleClose) {
1701
- t25 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", onClick: () => {
1729
+ t25 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "text", color: "primary", onClick: () => {
1702
1730
  handleClose();
1703
1731
  }, children: "Cancel" });
1704
1732
  $[53] = handleClose;
@@ -1707,70 +1735,63 @@
1707
1735
  t25 = $[54];
1708
1736
  }
1709
1737
  const t26 = !dirty;
1710
- let t27;
1711
- if ($[55] === Symbol.for("react.memo_cache_sentinel")) {
1712
- t27 = /* @__PURE__ */ jsxRuntime.jsx(ui.CheckIcon, {});
1713
- $[55] = t27;
1714
- } else {
1715
- t27 = $[55];
1716
- }
1717
- const t28 = isNewUser ? "Create user" : "Update";
1718
- let t29;
1719
- if ($[56] !== isSubmitting || $[57] !== t26 || $[58] !== t28) {
1720
- t29 = /* @__PURE__ */ jsxRuntime.jsx(ui.LoadingButton, { variant: "filled", color: "primary", type: "submit", disabled: t26, loading: isSubmitting, startIcon: t27, children: t28 });
1721
- $[56] = isSubmitting;
1722
- $[57] = t26;
1738
+ const t27 = isNewUser ? "Create user" : "Update";
1739
+ let t28;
1740
+ if ($[55] !== isSubmitting || $[56] !== t26 || $[57] !== t27) {
1741
+ t28 = /* @__PURE__ */ jsxRuntime.jsx(ui.LoadingButton, { variant: "filled", color: "primary", type: "submit", disabled: t26, loading: isSubmitting, children: t27 });
1742
+ $[55] = isSubmitting;
1743
+ $[56] = t26;
1744
+ $[57] = t27;
1723
1745
  $[58] = t28;
1724
- $[59] = t29;
1725
1746
  } else {
1726
- t29 = $[59];
1747
+ t28 = $[58];
1727
1748
  }
1728
- let t30;
1729
- if ($[60] !== t25 || $[61] !== t29) {
1730
- t30 = /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogActions, { children: [
1749
+ let t29;
1750
+ if ($[59] !== t25 || $[60] !== t28) {
1751
+ t29 = /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogActions, { children: [
1731
1752
  t25,
1732
- t29
1753
+ t28
1733
1754
  ] });
1734
- $[60] = t25;
1755
+ $[59] = t25;
1756
+ $[60] = t28;
1735
1757
  $[61] = t29;
1736
- $[62] = t30;
1737
1758
  } else {
1738
- t30 = $[62];
1759
+ t29 = $[61];
1739
1760
  }
1740
- let t31;
1741
- if ($[63] !== handleSubmit || $[64] !== t24 || $[65] !== t30) {
1742
- t31 = /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, autoComplete: "off", noValidate: true, style: t6, children: [
1761
+ let t30;
1762
+ if ($[62] !== handleSubmit || $[63] !== t24 || $[64] !== t29) {
1763
+ t30 = /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, autoComplete: "off", noValidate: true, style: t6, children: [
1743
1764
  t7,
1744
1765
  t24,
1745
- t30
1766
+ t29
1746
1767
  ] });
1747
- $[63] = handleSubmit;
1748
- $[64] = t24;
1768
+ $[62] = handleSubmit;
1769
+ $[63] = t24;
1770
+ $[64] = t29;
1749
1771
  $[65] = t30;
1750
- $[66] = t31;
1751
1772
  } else {
1752
- t31 = $[66];
1773
+ t30 = $[65];
1753
1774
  }
1754
- let t32;
1755
- if ($[67] !== formex$1 || $[68] !== t31) {
1756
- t32 = /* @__PURE__ */ jsxRuntime.jsx(formex.Formex, { value: formex$1, children: t31 });
1757
- $[67] = formex$1;
1775
+ let t31;
1776
+ if ($[66] !== formex$1 || $[67] !== t30) {
1777
+ t31 = /* @__PURE__ */ jsxRuntime.jsx(formex.Formex, { value: formex$1, children: t30 });
1778
+ $[66] = formex$1;
1779
+ $[67] = t30;
1758
1780
  $[68] = t31;
1759
- $[69] = t32;
1760
1781
  } else {
1761
- t32 = $[69];
1782
+ t31 = $[68];
1762
1783
  }
1763
- let t33;
1764
- if ($[70] !== open || $[71] !== t32 || $[72] !== t5) {
1765
- t33 = /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open, onOpenChange: t5, maxWidth: "4xl", children: t32 });
1766
- $[70] = open;
1767
- $[71] = t32;
1768
- $[72] = t5;
1769
- $[73] = t33;
1784
+ let t32;
1785
+ if ($[69] !== open || $[70] !== t31 || $[71] !== t5) {
1786
+ t32 = /* @__PURE__ */ jsxRuntime.jsx(ui.Dialog, { open, onOpenChange: t5, maxWidth: "4xl", children: t31 });
1787
+ $[69] = open;
1788
+ $[70] = t31;
1789
+ $[71] = t5;
1790
+ $[72] = t32;
1770
1791
  } else {
1771
- t33 = $[73];
1792
+ t32 = $[72];
1772
1793
  }
1773
- return t33;
1794
+ return t32;
1774
1795
  }
1775
1796
  function _temp7(userRole) {
1776
1797
  return /* @__PURE__ */ jsxRuntime.jsx(ui.MultiSelectItem, { value: userRole.id, children: /* @__PURE__ */ jsxRuntime.jsx(RoleChip, { role: userRole }, userRole?.id) }, userRole.id);