@rebasepro/client-firebase 0.3.0 → 0.4.0
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/hooks/useBuildUserManagement.d.ts +6 -1
- package/dist/hooks/useFirebaseAuthController.d.ts +2 -2
- package/dist/index.es.js +9 -11
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/types/auth.d.ts +2 -2
- package/package.json +7 -7
- package/src/hooks/useBuildUserManagement.tsx +11 -6
- package/src/hooks/useFirebaseAuthController.ts +6 -8
- package/src/types/auth.tsx +2 -2
- package/src/utils/collections_firestore.ts +4 -2
- package/src/utils/rebase_search_controller.ts +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
const [userRoles, _setUserRoles] = React.useState();
|
|
20
20
|
const [extra, setExtra] = React.useState();
|
|
21
21
|
const setUserRoles = React.useCallback((roles) => {
|
|
22
|
-
|
|
23
|
-
const newRoleIds = roles?.map((r_0) => r_0.id);
|
|
24
|
-
if (!fastEquals.deepEqual(currentRoleIds, newRoleIds)) {
|
|
22
|
+
if (!fastEquals.deepEqual(userRoles, roles)) {
|
|
25
23
|
_setUserRoles(roles);
|
|
26
24
|
}
|
|
27
25
|
}, [userRoles]);
|
|
@@ -209,8 +207,7 @@
|
|
|
209
207
|
}, []);
|
|
210
208
|
const firebaseUserWrapper = loggedUser ? {
|
|
211
209
|
...loggedUser,
|
|
212
|
-
roles: userRoles
|
|
213
|
-
// User.roles is string[], keep Role[] internally only
|
|
210
|
+
roles: userRoles,
|
|
214
211
|
firebaseUser: loggedUser
|
|
215
212
|
} : null;
|
|
216
213
|
return {
|
|
@@ -599,7 +596,8 @@
|
|
|
599
596
|
if (normalizedProperty.enum) {
|
|
600
597
|
normalizedProperty.enum = normalizeEnumValuesToArray(normalizedProperty.enum, sortObjectFormat);
|
|
601
598
|
}
|
|
602
|
-
|
|
599
|
+
const propType = normalizedProperty.type ?? normalizedProperty.dataType;
|
|
600
|
+
if (propType === "array" && typeof normalizedProperty.of === "object" && normalizedProperty.of !== null) {
|
|
603
601
|
const ofProp = normalizedProperty.of;
|
|
604
602
|
if (ofProp.enum) {
|
|
605
603
|
normalizedProperty.of = {
|
|
@@ -608,7 +606,7 @@
|
|
|
608
606
|
};
|
|
609
607
|
}
|
|
610
608
|
}
|
|
611
|
-
if (
|
|
609
|
+
if (propType === "map" && normalizedProperty.properties) {
|
|
612
610
|
normalizedProperty.properties = normalizePropertiesEnumValues(normalizedProperty.properties, sortObjectFormat);
|
|
613
611
|
}
|
|
614
612
|
result[key] = normalizedProperty;
|
|
@@ -2009,8 +2007,8 @@
|
|
|
2009
2007
|
if (!usersWithRoleIds) throw Error("Users not loaded");
|
|
2010
2008
|
const mgmtUser = usersWithRoleIds.find((u_1) => u_1.email?.toLowerCase() === user_1?.email?.toLowerCase());
|
|
2011
2009
|
if (!mgmtUser || !mgmtUser.roles) return void 0;
|
|
2012
|
-
return
|
|
2013
|
-
}, [
|
|
2010
|
+
return mgmtUser.roles;
|
|
2011
|
+
}, [usersWithRoleIds]);
|
|
2014
2012
|
const accessGate = React.useCallback(({
|
|
2015
2013
|
user: user_2
|
|
2016
2014
|
}) => {
|
|
@@ -2050,8 +2048,8 @@
|
|
|
2050
2048
|
throw Error("Could not find a user with the provided email in the user management system.");
|
|
2051
2049
|
}, [loading, users]);
|
|
2052
2050
|
const userRoles = authController.user ? defineRolesFor(authController.user) : void 0;
|
|
2053
|
-
const isAdmin = (userRoles ?? []).some((
|
|
2054
|
-
const userRoleIds = userRoles
|
|
2051
|
+
const isAdmin = (userRoles ?? []).some((r) => r === "admin");
|
|
2052
|
+
const userRoleIds = userRoles;
|
|
2055
2053
|
React.useEffect(() => {
|
|
2056
2054
|
console.debug("Setting user roles", {
|
|
2057
2055
|
userRoles,
|