@frontegg/redux-store 7.100.0-alpha.0 → 7.100.0-alpha.2

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.
@@ -11,23 +11,6 @@ export default ((store, api, sharedActions) => {
11
11
  const resetProfileState = () => {
12
12
  deepResetState(store, ['auth', 'profileState'], initialState);
13
13
  };
14
-
15
- /**
16
- * Helper function to preserve groups from currentUser if profile doesn't have them
17
- * The authorization API returns merged roles/permissions but may not include groups array
18
- * @param profileData - User profile data from API (may or may not have groups)
19
- * @param currentUser - Current user from store (has groups if they were loaded before)
20
- * @returns Groups array to use (prefers profile.groups if they exist, otherwise currentUser.groups)
21
- */
22
- const preserveGroups = (profileData, currentUser) => {
23
- if (profileData != null && profileData.groups && profileData.groups.length > 0) {
24
- return profileData.groups;
25
- }
26
- if (currentUser != null && currentUser.groups && currentUser.groups.length > 0) {
27
- return currentUser.groups;
28
- }
29
- return profileData == null ? void 0 : profileData.groups;
30
- };
31
14
  const loadProfile = async () => {
32
15
  setProfileState({
33
16
  loading: true
@@ -35,10 +18,7 @@ export default ((store, api, sharedActions) => {
35
18
  try {
36
19
  const profile = await retry(api.auth.getMeAndEntitlements, 3, 2000);
37
20
  const currentUser = store.auth.user;
38
- const preservedGroups = preserveGroups(profile, currentUser);
39
- const mergedUser = _extends({}, currentUser, profile, {
40
- groups: preservedGroups
41
- });
21
+ const mergedUser = _extends({}, currentUser, profile);
42
22
  actions.setUser(mergedUser);
43
23
  setProfileState({
44
24
  profile,
@@ -141,17 +121,14 @@ export default ((store, api, sharedActions) => {
141
121
  await api.users.updateUserProfileV2(newProfileData);
142
122
  const currentUser = store.auth.user;
143
123
  const completeUserData = await retry(api.auth.getMeAndEntitlements, 3, 2000);
144
- const preservedGroups = preserveGroups(completeUserData, currentUser);
145
- const mergedUser = _extends({}, currentUser, completeUserData, {
146
- groups: preservedGroups
147
- });
124
+ const mergedUser = _extends({}, currentUser, completeUserData);
148
125
  actions.setUser(mergedUser);
149
126
  actions.setProfileState({
150
127
  profile: completeUserData,
151
128
  saving: false,
152
129
  loading: false
153
130
  });
154
- callback == null ? void 0 : callback(newProfileData);
131
+ callback == null ? void 0 : callback(completeUserData);
155
132
  } catch (e) {
156
133
  setProfileState({
157
134
  saving: false,
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.100.0-alpha.0
1
+ /** @license Frontegg v7.100.0-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -18,23 +18,6 @@ var _default = (store, api, sharedActions) => {
18
18
  const resetProfileState = () => {
19
19
  (0, _helpers.deepResetState)(store, ['auth', 'profileState'], _state.initialState);
20
20
  };
21
-
22
- /**
23
- * Helper function to preserve groups from currentUser if profile doesn't have them
24
- * The authorization API returns merged roles/permissions but may not include groups array
25
- * @param profileData - User profile data from API (may or may not have groups)
26
- * @param currentUser - Current user from store (has groups if they were loaded before)
27
- * @returns Groups array to use (prefers profile.groups if they exist, otherwise currentUser.groups)
28
- */
29
- const preserveGroups = (profileData, currentUser) => {
30
- if (profileData != null && profileData.groups && profileData.groups.length > 0) {
31
- return profileData.groups;
32
- }
33
- if (currentUser != null && currentUser.groups && currentUser.groups.length > 0) {
34
- return currentUser.groups;
35
- }
36
- return profileData == null ? void 0 : profileData.groups;
37
- };
38
21
  const loadProfile = async () => {
39
22
  setProfileState({
40
23
  loading: true
@@ -42,10 +25,7 @@ var _default = (store, api, sharedActions) => {
42
25
  try {
43
26
  const profile = await (0, _helpers.retry)(api.auth.getMeAndEntitlements, 3, 2000);
44
27
  const currentUser = store.auth.user;
45
- const preservedGroups = preserveGroups(profile, currentUser);
46
- const mergedUser = (0, _extends2.default)({}, currentUser, profile, {
47
- groups: preservedGroups
48
- });
28
+ const mergedUser = (0, _extends2.default)({}, currentUser, profile);
49
29
  actions.setUser(mergedUser);
50
30
  setProfileState({
51
31
  profile,
@@ -148,17 +128,14 @@ var _default = (store, api, sharedActions) => {
148
128
  await api.users.updateUserProfileV2(newProfileData);
149
129
  const currentUser = store.auth.user;
150
130
  const completeUserData = await (0, _helpers.retry)(api.auth.getMeAndEntitlements, 3, 2000);
151
- const preservedGroups = preserveGroups(completeUserData, currentUser);
152
- const mergedUser = (0, _extends2.default)({}, currentUser, completeUserData, {
153
- groups: preservedGroups
154
- });
131
+ const mergedUser = (0, _extends2.default)({}, currentUser, completeUserData);
155
132
  actions.setUser(mergedUser);
156
133
  actions.setProfileState({
157
134
  profile: completeUserData,
158
135
  saving: false,
159
136
  loading: false
160
137
  });
161
- callback == null ? void 0 : callback(newProfileData);
138
+ callback == null ? void 0 : callback(completeUserData);
162
139
  } catch (e) {
163
140
  setProfileState({
164
141
  saving: false,
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.100.0-alpha.0
1
+ /** @license Frontegg v7.100.0-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
- "version": "7.100.0-alpha.0",
3
+ "version": "7.100.0-alpha.2",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.18.6",
9
9
  "@frontegg/entitlements-javascript-commons": "1.1.2",
10
- "@frontegg/rest-api": "7.100.0-alpha.0",
10
+ "@frontegg/rest-api": "7.100.0-alpha.2",
11
11
  "fast-deep-equal": "3.1.3",
12
12
  "get-value": "^3.0.1",
13
13
  "proxy-compare": "^3.0.0",