@frontegg/redux-store 6.185.0-alpha.3 → 6.186.0-alpha.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/auth/AcceptInvitationState/index.d.ts +2 -0
- package/auth/AccountSettingsState/index.d.ts +2 -0
- package/auth/ActivateState/index.d.ts +3 -0
- package/auth/ApiTokensState/index.d.ts +2 -0
- package/auth/ApplicationsState/index.d.ts +83 -0
- package/auth/ApplicationsState/index.js +36 -0
- package/auth/ApplicationsState/interfaces.d.ts +12 -0
- package/auth/ApplicationsState/interfaces.js +1 -0
- package/auth/ApplicationsState/saga.d.ts +48 -0
- package/auth/ApplicationsState/saga.js +250 -0
- package/auth/ApplicationsState/utils/getFlattenAppIds.d.ts +3 -0
- package/auth/ApplicationsState/utils/getFlattenAppIds.js +13 -0
- package/auth/CustomLoginState/index.d.ts +2 -0
- package/auth/ForgotPasswordState/index.d.ts +2 -0
- package/auth/GroupsState/groupsDialogsState.d.ts +12 -0
- package/auth/GroupsState/index.d.ts +2 -0
- package/auth/ImpersonationState/index.d.ts +2 -0
- package/auth/LoginState/index.d.ts +2 -0
- package/auth/LoginState/saga.js +1 -1
- package/auth/MSP/AllAccountsState/allAccountsDialogsState.d.ts +14 -0
- package/auth/MSP/AllAccountsState/index.d.ts +3 -0
- package/auth/MfaState/index.d.ts +2 -0
- package/auth/PasskeysState/index.d.ts +2 -0
- package/auth/ProfileState/index.d.ts +2 -0
- package/auth/Provisioning/index.d.ts +2 -0
- package/auth/ResetPhoneNumberState/index.d.ts +2 -0
- package/auth/RolesState/index.d.ts +2 -0
- package/auth/SSOState/index.d.ts +2 -0
- package/auth/Security/RestrictionsState/index.d.ts +3 -0
- package/auth/Security/SecurityCenterState/index.d.ts +2 -0
- package/auth/Security/SecurityPolicyState/index.d.ts +13 -0
- package/auth/Security/SessionsPolicyState/index.d.ts +2 -0
- package/auth/SessionsState/index.d.ts +2 -0
- package/auth/SignUp/index.d.ts +2 -0
- package/auth/SmsState/index.d.ts +2 -0
- package/auth/SocialLogins/index.d.ts +2 -0
- package/auth/StepUpState/index.d.ts +2 -0
- package/auth/TeamState/index.d.ts +6 -4
- package/auth/TeamState/interfaces.d.ts +7 -1
- package/auth/TeamState/saga.js +21 -6
- package/auth/TenantsState/index.d.ts +2 -0
- package/auth/index.d.ts +9 -2
- package/auth/index.js +2 -0
- package/auth/initialState.js +2 -0
- package/auth/interfaces.d.ts +2 -0
- package/auth/reducer.d.ts +9 -3
- package/auth/reducer.js +3 -2
- package/auth/saga.js +2 -1
- package/auth/utils.d.ts +6 -0
- package/index.js +1 -1
- package/node/auth/ApplicationsState/index.js +43 -0
- package/node/auth/ApplicationsState/interfaces.js +5 -0
- package/node/auth/ApplicationsState/saga.js +264 -0
- package/node/auth/ApplicationsState/utils/getFlattenAppIds.js +20 -0
- package/node/auth/LoginState/saga.js +1 -1
- package/node/auth/TeamState/saga.js +21 -6
- package/node/auth/index.js +24 -0
- package/node/auth/initialState.js +2 -0
- package/node/auth/reducer.js +3 -2
- package/node/auth/saga.js +2 -1
- package/node/index.js +1 -1
- package/package.json +2 -2
- package/toolkit/index.d.ts +1 -1
package/auth/TeamState/saga.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["callback"],
|
|
3
|
+
const _excluded = ["callback", "appIds"],
|
|
4
4
|
_excluded2 = ["roles"],
|
|
5
5
|
_excluded3 = ["callback"],
|
|
6
6
|
_excluded4 = ["callback", "profileImage"],
|
|
@@ -34,6 +34,7 @@ import { allUsersDemo, permissionsDemo, rolesDemo, usersDemo, userTeamDemo } fro
|
|
|
34
34
|
import { v4 as uuidv4 } from 'uuid';
|
|
35
35
|
import { GroupRelations } from '../GroupsState/interfaces';
|
|
36
36
|
import { errorHandler } from '../../utils';
|
|
37
|
+
import { assignNewUserToApps, mapUsersWithApplicationData } from '../ApplicationsState/saga';
|
|
37
38
|
const selectTeamState = () => sagaSelect(_ => _[authStoreName].teamState);
|
|
38
39
|
function* getGroupsForUsers() {
|
|
39
40
|
try {
|
|
@@ -55,7 +56,8 @@ function* loadUsersV2({
|
|
|
55
56
|
var _payload$pageSize, _payload$pageOffset, _payload$filter, _payload$sort, _payload$shouldShowSu;
|
|
56
57
|
const {
|
|
57
58
|
silentLoading,
|
|
58
|
-
callback
|
|
59
|
+
callback,
|
|
60
|
+
shouldLoadApps
|
|
59
61
|
} = payload;
|
|
60
62
|
const teamState = yield selectTeamState();
|
|
61
63
|
const pageSize = (_payload$pageSize = payload.pageSize) != null ? _payload$pageSize : teamState.pageSize;
|
|
@@ -104,10 +106,15 @@ function* loadUsersV2({
|
|
|
104
106
|
groups: userGroupsFullData
|
|
105
107
|
});
|
|
106
108
|
});
|
|
109
|
+
const userWithRoleIds = usersWithGroups.map(user => _extends({}, user, {
|
|
110
|
+
roleIds: user.roles.map(role => role.id)
|
|
111
|
+
}));
|
|
112
|
+
const mappedUsers = yield call(mapUsersWithApplicationData, {
|
|
113
|
+
shouldLoadApps,
|
|
114
|
+
users: userWithRoleIds
|
|
115
|
+
});
|
|
107
116
|
yield put(actions.setTeamState({
|
|
108
|
-
users:
|
|
109
|
-
roleIds: user.roles.map(role => role.id)
|
|
110
|
-
})),
|
|
117
|
+
users: mappedUsers,
|
|
111
118
|
totalPages,
|
|
112
119
|
totalItems,
|
|
113
120
|
roles,
|
|
@@ -299,7 +306,8 @@ function* addUser({
|
|
|
299
306
|
payload
|
|
300
307
|
}) {
|
|
301
308
|
const {
|
|
302
|
-
callback
|
|
309
|
+
callback,
|
|
310
|
+
appIds
|
|
303
311
|
} = payload,
|
|
304
312
|
body = _objectWithoutPropertiesLoose(payload, _excluded);
|
|
305
313
|
const teamState = yield selectTeamState();
|
|
@@ -319,6 +327,13 @@ function* addUser({
|
|
|
319
327
|
const newUser = _extends({}, userWithoutRoleIds, {
|
|
320
328
|
roleIds
|
|
321
329
|
});
|
|
330
|
+
const apps = yield call(assignNewUserToApps, {
|
|
331
|
+
appIds,
|
|
332
|
+
user: newUser
|
|
333
|
+
});
|
|
334
|
+
if (apps) {
|
|
335
|
+
newUser.applications = apps;
|
|
336
|
+
}
|
|
322
337
|
callback == null ? void 0 : callback(newUser);
|
|
323
338
|
yield put(actions.setTeamState({
|
|
324
339
|
users: [newUser, ...teamState.users],
|
|
@@ -56,6 +56,7 @@ declare const reducers: {
|
|
|
56
56
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
57
57
|
smsState?: import("..").SmsState | undefined;
|
|
58
58
|
stepUpState?: import("..").StepUpState | undefined;
|
|
59
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
59
60
|
routes: import("..").AuthPageRoutes;
|
|
60
61
|
header?: any;
|
|
61
62
|
loaderComponent?: any;
|
|
@@ -107,6 +108,7 @@ declare const reducers: {
|
|
|
107
108
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
108
109
|
smsState?: import("..").SmsState | undefined;
|
|
109
110
|
stepUpState?: import("..").StepUpState | undefined;
|
|
111
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
110
112
|
routes: import("..").AuthPageRoutes;
|
|
111
113
|
header?: any;
|
|
112
114
|
loaderComponent?: any;
|
package/auth/index.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export * from './Security/SecurityCenterState/interfaces';
|
|
|
61
61
|
export * from './Security/SecurityCenterState/types';
|
|
62
62
|
export * from './CustomLoginState';
|
|
63
63
|
export * from './CustomLoginState/interfaces';
|
|
64
|
+
export * from './ApplicationsState';
|
|
65
|
+
export * from './ApplicationsState/interfaces';
|
|
64
66
|
export * from './MSP/AllAccountsState';
|
|
65
67
|
export * from './MSP/AllAccountsState/types';
|
|
66
68
|
export * from './MSP/AllAccountsState/allAccountsDialogsState';
|
|
@@ -319,9 +321,9 @@ declare const _default: {
|
|
|
319
321
|
} | undefined, string, never, never>;
|
|
320
322
|
openAddUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import("./TeamState/interfaces").AddUserDialogState, "onClose"> | undefined)?], Pick<import("./TeamState/interfaces").AddUserDialogState, "onClose"> | undefined, string, never, never>;
|
|
321
323
|
closeAddUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[any?], any, string, never, never>;
|
|
322
|
-
openDeleteUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import("./TeamState/interfaces").DeleteUserDialogState, "
|
|
324
|
+
openDeleteUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import("./TeamState/interfaces").DeleteUserDialogState, "userId" | "onClose" | "email"> | undefined)?], Pick<import("./TeamState/interfaces").DeleteUserDialogState, "userId" | "onClose" | "email"> | undefined, string, never, never>;
|
|
323
325
|
closeDeleteUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[any?], any, string, never, never>;
|
|
324
|
-
openLockUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import("./TeamState/interfaces").DeleteUserDialogState, "
|
|
326
|
+
openLockUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import("./TeamState/interfaces").DeleteUserDialogState, "userId" | "onClose" | "email"> | undefined)?], Pick<import("./TeamState/interfaces").DeleteUserDialogState, "userId" | "onClose" | "email"> | undefined, string, never, never>;
|
|
325
327
|
closeLockUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[any?], any, string, never, never>;
|
|
326
328
|
enrollMfa: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
327
329
|
getMFADevices: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
@@ -463,6 +465,10 @@ declare const _default: {
|
|
|
463
465
|
}, boolean>, string, never, never>;
|
|
464
466
|
createSamlGroup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import("@frontegg/rest-api").ICreateSamlGroup, boolean>], import("..").WithCallback<import("@frontegg/rest-api").ICreateSamlGroup, boolean>, string, never, never>;
|
|
465
467
|
oidcPostlogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IOidcPostLogin], import("@frontegg/rest-api").IOidcPostLogin, string, never, never>;
|
|
468
|
+
loadUserApplications: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
469
|
+
loadAccountApplications: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
470
|
+
assignUserToApps: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>], import("..").WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>, string, never, never>;
|
|
471
|
+
unassignUserFromApps: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>], import("..").WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>, string, never, never>;
|
|
466
472
|
loadTenantMetadata: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
467
473
|
updateTenantMetadata: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<Partial<import("./CustomLoginState/interfaces").UpdateTenantMetadataRequest>, boolean>], import("..").WithCallback<Partial<import("./CustomLoginState/interfaces").UpdateTenantMetadataRequest>, boolean>, string, never, never>;
|
|
468
474
|
loadProfile: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
@@ -756,6 +762,7 @@ declare const _default: {
|
|
|
756
762
|
resetSSOState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
757
763
|
setCustomLoginState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("./CustomLoginState/interfaces").CustomLoginState>], Partial<import("./CustomLoginState/interfaces").CustomLoginState>, string, never, never>;
|
|
758
764
|
resetCustomLoginState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
765
|
+
setApplicationsState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("./ApplicationsState/interfaces").ApplicationsState>], Partial<import("./ApplicationsState/interfaces").ApplicationsState>, string, never, never>;
|
|
759
766
|
setProfileState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("./ProfileState/interfaces").ProfileState>], Partial<import("./ProfileState/interfaces").ProfileState>, string, never, never>;
|
|
760
767
|
resetProfileState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
761
768
|
setSignUpState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("./SignUp/interfaces").SignUpState>], Partial<import("./SignUp/interfaces").SignUpState>, string, never, never>;
|
package/auth/index.js
CHANGED
|
@@ -63,6 +63,8 @@ export * from './Security/SecurityCenterState/interfaces';
|
|
|
63
63
|
export * from './Security/SecurityCenterState/types';
|
|
64
64
|
export * from './CustomLoginState';
|
|
65
65
|
export * from './CustomLoginState/interfaces';
|
|
66
|
+
export * from './ApplicationsState';
|
|
67
|
+
export * from './ApplicationsState/interfaces';
|
|
66
68
|
export * from './MSP/AllAccountsState';
|
|
67
69
|
export * from './MSP/AllAccountsState/types';
|
|
68
70
|
export * from './MSP/AllAccountsState/allAccountsDialogsState';
|
package/auth/initialState.js
CHANGED
|
@@ -29,6 +29,7 @@ import { securityCenterState } from './Security/SecurityCenterState';
|
|
|
29
29
|
import { defaultFronteggRoutes } from './LoginState/consts';
|
|
30
30
|
import { smsState } from './SmsState';
|
|
31
31
|
import { stepUpState } from './StepUpState';
|
|
32
|
+
import { applicationsState } from './ApplicationsState';
|
|
32
33
|
export const reinitializeState = {
|
|
33
34
|
isAuthenticated: false,
|
|
34
35
|
isLoading: true,
|
|
@@ -43,6 +44,7 @@ export const reinitializeState = {
|
|
|
43
44
|
ssoState,
|
|
44
45
|
profileState,
|
|
45
46
|
customLoginState,
|
|
47
|
+
applicationsState,
|
|
46
48
|
mfaState,
|
|
47
49
|
teamState,
|
|
48
50
|
groupsState,
|
package/auth/interfaces.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { CustomLoginState } from './CustomLoginState/interfaces';
|
|
|
27
27
|
import { IAllAccountsDialogsState, IAllAccountsState } from './MSP/AllAccountsState/types';
|
|
28
28
|
import { SecurityCenterState } from './Security/SecurityCenterState/interfaces';
|
|
29
29
|
import { StepUpState } from './StepUpState/interfaces';
|
|
30
|
+
import { ApplicationsState } from './ApplicationsState/interfaces';
|
|
30
31
|
interface Actor {
|
|
31
32
|
sub?: string;
|
|
32
33
|
}
|
|
@@ -99,6 +100,7 @@ export interface AuthState extends Routes, PluginOptions {
|
|
|
99
100
|
securityCenterState?: SecurityCenterState;
|
|
100
101
|
smsState?: SmsState;
|
|
101
102
|
stepUpState?: StepUpState;
|
|
103
|
+
applicationsState?: ApplicationsState;
|
|
102
104
|
}
|
|
103
105
|
export declare type AuthPageRoutes = {
|
|
104
106
|
/**
|
package/auth/reducer.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { SecurityCenterActions } from './Security/SecurityCenterState';
|
|
|
30
30
|
import { SmsActions } from './SmsState';
|
|
31
31
|
import { UserEntitlementsContext as UserEntitlementsResponseV2 } from '@frontegg/entitlements-javascript-commons';
|
|
32
32
|
import { LoadEntitlementsActionPayload } from './Entitlements/interfaces';
|
|
33
|
+
import { ApplicationsActions } from './ApplicationsState';
|
|
33
34
|
declare const reducer: import("redux").Reducer<AuthState, import("redux").AnyAction>;
|
|
34
35
|
declare const actions: {
|
|
35
36
|
loadPhoneNumbers: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
@@ -277,9 +278,9 @@ declare const actions: {
|
|
|
277
278
|
} | undefined, string, never, never>;
|
|
278
279
|
openAddUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import(".").AddUserDialogState, "onClose"> | undefined)?], Pick<import(".").AddUserDialogState, "onClose"> | undefined, string, never, never>;
|
|
279
280
|
closeAddUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[any?], any, string, never, never>;
|
|
280
|
-
openDeleteUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import(".").DeleteUserDialogState, "
|
|
281
|
+
openDeleteUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import(".").DeleteUserDialogState, "userId" | "onClose" | "email"> | undefined)?], Pick<import(".").DeleteUserDialogState, "userId" | "onClose" | "email"> | undefined, string, never, never>;
|
|
281
282
|
closeDeleteUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[any?], any, string, never, never>;
|
|
282
|
-
openLockUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import(".").DeleteUserDialogState, "
|
|
283
|
+
openLockUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Pick<import(".").DeleteUserDialogState, "userId" | "onClose" | "email"> | undefined)?], Pick<import(".").DeleteUserDialogState, "userId" | "onClose" | "email"> | undefined, string, never, never>;
|
|
283
284
|
closeLockUserDialog: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[any?], any, string, never, never>;
|
|
284
285
|
enrollMfa: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
285
286
|
getMFADevices: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
@@ -421,6 +422,10 @@ declare const actions: {
|
|
|
421
422
|
}, boolean>, string, never, never>;
|
|
422
423
|
createSamlGroup: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import("@frontegg/rest-api").ICreateSamlGroup, boolean>], import("..").WithCallback<import("@frontegg/rest-api").ICreateSamlGroup, boolean>, string, never, never>;
|
|
423
424
|
oidcPostlogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IOidcPostLogin], import("@frontegg/rest-api").IOidcPostLogin, string, never, never>;
|
|
425
|
+
loadUserApplications: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
426
|
+
loadAccountApplications: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
427
|
+
assignUserToApps: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>], import("..").WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>, string, never, never>;
|
|
428
|
+
unassignUserFromApps: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>], import("..").WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>, string, never, never>;
|
|
424
429
|
loadTenantMetadata: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
425
430
|
updateTenantMetadata: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<Partial<import(".").UpdateTenantMetadataRequest>, boolean>], import("..").WithCallback<Partial<import(".").UpdateTenantMetadataRequest>, boolean>, string, never, never>;
|
|
426
431
|
loadProfile: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
@@ -714,6 +719,7 @@ declare const actions: {
|
|
|
714
719
|
resetSSOState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
715
720
|
setCustomLoginState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import(".").CustomLoginState>], Partial<import(".").CustomLoginState>, string, never, never>;
|
|
716
721
|
resetCustomLoginState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
722
|
+
setApplicationsState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import(".").ApplicationsState>], Partial<import(".").ApplicationsState>, string, never, never>;
|
|
717
723
|
setProfileState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import(".").ProfileState>], Partial<import(".").ProfileState>, string, never, never>;
|
|
718
724
|
resetProfileState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
719
725
|
setSignUpState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import(".").SignUpState>], Partial<import(".").SignUpState>, string, never, never>;
|
|
@@ -748,5 +754,5 @@ export declare type RootActions = {
|
|
|
748
754
|
setEntitlements: (entitlements: Partial<UserEntitlementsResponseV2>) => void;
|
|
749
755
|
loadEntitlements: (payload?: LoadEntitlementsActionPayload) => void;
|
|
750
756
|
};
|
|
751
|
-
export declare type AuthActions = RootActions & LoginActions & StepUpActions & SocialLoginActions & ActivateAccountActions & ImpersonateActions & AcceptInvitationActions & ForgotPasswordActions & ResetPhoneNumberActions & SignUpActions & ProfileActions & CustomLoginActions & SSOActions & MfaActions & TeamActions & GroupsActions & GroupsDialogsActions & ApiTokensActions & SecurityPolicyActions & AccountSettingsActions & TenantsActions & RolesActions & SessionsActions & RestrictionsActions & ProvisioningActions & PasskeysActions & AllAccountsActions & AllAccountsDialogsActions & SecurityCenterActions & SmsActions;
|
|
757
|
+
export declare type AuthActions = RootActions & LoginActions & StepUpActions & SocialLoginActions & ActivateAccountActions & ImpersonateActions & AcceptInvitationActions & ForgotPasswordActions & ResetPhoneNumberActions & SignUpActions & ProfileActions & CustomLoginActions & ApplicationsActions & SSOActions & MfaActions & TeamActions & GroupsActions & GroupsDialogsActions & ApiTokensActions & SecurityPolicyActions & AccountSettingsActions & TenantsActions & RolesActions & SessionsActions & RestrictionsActions & ProvisioningActions & PasskeysActions & AllAccountsActions & AllAccountsDialogsActions & SecurityCenterActions & SmsActions;
|
|
752
758
|
export { reducer, actions };
|
package/auth/reducer.js
CHANGED
|
@@ -33,6 +33,7 @@ import { allAccountsActions, allAccountsReducers } from './MSP/AllAccountsState'
|
|
|
33
33
|
import { allAccountsDialogsReducers } from './MSP/AllAccountsState/allAccountsDialogsState';
|
|
34
34
|
import { securityCenterActions, securityCenterReducers } from './Security/SecurityCenterState';
|
|
35
35
|
import { smsActions, smsReducers } from './SmsState';
|
|
36
|
+
import { applicationsActions, applicationsReducers } from './ApplicationsState';
|
|
36
37
|
const {
|
|
37
38
|
reducer,
|
|
38
39
|
actions: sliceActions
|
|
@@ -46,11 +47,11 @@ const {
|
|
|
46
47
|
}) => _extends({}, state, payload),
|
|
47
48
|
setUser: typeReducer('user'),
|
|
48
49
|
setEntitlements: typeReducerNestedKey('user', 'entitlements')
|
|
49
|
-
}, loginReducers, stepUpReducers, socialLoginsReducer, activateAccountReducers, impersonateReducers, acceptInvitationReducers, forgotPasswordReducers, resetPhoneNumberReducers, signUpReducers, profileReducers, customLoginReducers, ssoReducers, mfaReducers, teamReducers, groupsReducers, groupsDialogsReducers, apiTokensReducers, securityPolicyReducers, accountSettingsReducers, tenantsReducers, rolesReducers, sessionsReducers, sessionsPolicyReducers, restrictionsReducers, provisioningReducers, passkeysReducers, allAccountsReducers, allAccountsDialogsReducers, securityCenterReducers, smsReducers)
|
|
50
|
+
}, loginReducers, stepUpReducers, socialLoginsReducer, activateAccountReducers, impersonateReducers, acceptInvitationReducers, forgotPasswordReducers, resetPhoneNumberReducers, signUpReducers, profileReducers, applicationsReducers, customLoginReducers, ssoReducers, mfaReducers, teamReducers, groupsReducers, groupsDialogsReducers, apiTokensReducers, securityPolicyReducers, accountSettingsReducers, tenantsReducers, rolesReducers, sessionsReducers, sessionsPolicyReducers, restrictionsReducers, provisioningReducers, passkeysReducers, allAccountsReducers, allAccountsDialogsReducers, securityCenterReducers, smsReducers)
|
|
50
51
|
});
|
|
51
52
|
const actions = _extends({
|
|
52
53
|
loadEntitlements: createAction(`${authStoreName}/loadEntitlements`, payload => ({
|
|
53
54
|
payload
|
|
54
55
|
}))
|
|
55
|
-
}, sliceActions, loginActions, stepUpActions, socialLoginsActions, activateAccountActions, acceptInvitationActions, forgotPasswordActions, resetPhoneNumberActions, signUpActions, profileActions, customLoginActions, ssoActions, mfaActions, teamActions, groupsActions, groupsDialogsActions, apiTokensActions, securityPolicyActions, accountSettingsActions, tenantsActions, rolesActions, sessionsActions, sessionsPolicyActions, restrictionsActions, provisioningActions, impersonateActions, passkeysActions, allAccountsActions, securityCenterActions, smsActions);
|
|
56
|
+
}, sliceActions, loginActions, stepUpActions, socialLoginsActions, activateAccountActions, acceptInvitationActions, forgotPasswordActions, resetPhoneNumberActions, signUpActions, profileActions, customLoginActions, applicationsActions, ssoActions, mfaActions, teamActions, groupsActions, groupsDialogsActions, apiTokensActions, securityPolicyActions, accountSettingsActions, tenantsActions, rolesActions, sessionsActions, sessionsPolicyActions, restrictionsActions, provisioningActions, impersonateActions, passkeysActions, allAccountsActions, securityCenterActions, smsActions);
|
|
56
57
|
export { reducer, actions };
|
package/auth/saga.js
CHANGED
|
@@ -29,8 +29,9 @@ import { entitlementsSagas } from './Entitlements/saga';
|
|
|
29
29
|
import { securityCenterSagas, securityCenterSagasMock } from './Security/SecurityCenterState/saga';
|
|
30
30
|
import { smsSagas } from './SmsState/saga';
|
|
31
31
|
import { stepUpSagas } from './StepUpState/saga';
|
|
32
|
+
import { applicationsSaga } from './ApplicationsState/saga';
|
|
32
33
|
export function* sagas() {
|
|
33
|
-
yield all([call(loginSagas), call(stepUpSagas), call(activateSagas), call(acceptInvitationSagas), call(forgotPasswordSagas), call(resetPhoneNumberSagas), call(ssoSagas), call(ssoSagasV2), call(profileSagas), call(customLoginSagas), call(mfaSagas), call(teamSagas), call(groupsSagas), call(socialLoginsSaga), call(signUpSaga), call(apiTokensSaga), call(securityPolicySagas), call(accountSettingsSaga), call(tenantsSagas), call(rolesSagas), call(sessionsSaga), call(sessionsPolicySaga), call(restrictionsSagas), call(provisionSagas), call(impersonateSagas), call(passkeysSagas), call(allAccountsSagas), call(entitlementsSagas), call(securityCenterSagas), call(smsSagas)]);
|
|
34
|
+
yield all([call(loginSagas), call(stepUpSagas), call(activateSagas), call(acceptInvitationSagas), call(forgotPasswordSagas), call(resetPhoneNumberSagas), call(ssoSagas), call(ssoSagasV2), call(profileSagas), call(customLoginSagas), call(mfaSagas), call(teamSagas), call(groupsSagas), call(socialLoginsSaga), call(signUpSaga), call(apiTokensSaga), call(securityPolicySagas), call(accountSettingsSaga), call(tenantsSagas), call(rolesSagas), call(sessionsSaga), call(sessionsPolicySaga), call(restrictionsSagas), call(provisionSagas), call(impersonateSagas), call(passkeysSagas), call(allAccountsSagas), call(entitlementsSagas), call(securityCenterSagas), call(smsSagas), call(applicationsSaga)]);
|
|
34
35
|
}
|
|
35
36
|
export function* mockSagas() {
|
|
36
37
|
yield all([call(loginSagasMock),
|
package/auth/utils.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export declare const resetStateByKey: <T>(key: keyof AuthState, initialState: Pa
|
|
|
46
46
|
securityCenterState?: import(".").SecurityCenterState | undefined;
|
|
47
47
|
smsState?: import(".").SmsState | undefined;
|
|
48
48
|
stepUpState?: import(".").StepUpState | undefined;
|
|
49
|
+
applicationsState?: import(".").ApplicationsState | undefined;
|
|
49
50
|
routes: import("./interfaces").AuthPageRoutes;
|
|
50
51
|
header?: any;
|
|
51
52
|
loaderComponent?: any;
|
|
@@ -99,6 +100,7 @@ export declare const typeReducer: <T>(key: keyof AuthState) => (state: AuthState
|
|
|
99
100
|
securityCenterState?: import(".").SecurityCenterState | undefined;
|
|
100
101
|
smsState?: import(".").SmsState | undefined;
|
|
101
102
|
stepUpState?: import(".").StepUpState | undefined;
|
|
103
|
+
applicationsState?: import(".").ApplicationsState | undefined;
|
|
102
104
|
routes: import("./interfaces").AuthPageRoutes;
|
|
103
105
|
header?: any;
|
|
104
106
|
loaderComponent?: any;
|
|
@@ -156,6 +158,7 @@ export declare const typeReducerForKey: <T>(key: keyof AuthState) => {
|
|
|
156
158
|
securityCenterState?: import(".").SecurityCenterState | undefined;
|
|
157
159
|
smsState?: import(".").SmsState | undefined;
|
|
158
160
|
stepUpState?: import(".").StepUpState | undefined;
|
|
161
|
+
applicationsState?: import(".").ApplicationsState | undefined;
|
|
159
162
|
routes: import("./interfaces").AuthPageRoutes;
|
|
160
163
|
header?: any;
|
|
161
164
|
loaderComponent?: any;
|
|
@@ -214,6 +217,7 @@ export declare const typeReducerNestedKey: <T, K>(key: keyof AuthState, nestedKe
|
|
|
214
217
|
securityCenterState?: import(".").SecurityCenterState | undefined;
|
|
215
218
|
smsState?: import(".").SmsState | undefined;
|
|
216
219
|
stepUpState?: import(".").StepUpState | undefined;
|
|
220
|
+
applicationsState?: import(".").ApplicationsState | undefined;
|
|
217
221
|
routes: import("./interfaces").AuthPageRoutes;
|
|
218
222
|
header?: any;
|
|
219
223
|
loaderComponent?: any;
|
|
@@ -296,6 +300,7 @@ export declare const dialogStateForKey: <T, K>(key: keyof AuthState, dialogKey:
|
|
|
296
300
|
securityCenterState?: import(".").SecurityCenterState | undefined;
|
|
297
301
|
smsState?: import(".").SmsState | undefined;
|
|
298
302
|
stepUpState?: import(".").StepUpState | undefined;
|
|
303
|
+
applicationsState?: import(".").ApplicationsState | undefined;
|
|
299
304
|
routes: import("./interfaces").AuthPageRoutes;
|
|
300
305
|
header?: any;
|
|
301
306
|
loaderComponent?: any;
|
|
@@ -347,6 +352,7 @@ export declare const dialogStateForKeyWithoutPayload: <T, K>(key: keyof AuthStat
|
|
|
347
352
|
securityCenterState?: import(".").SecurityCenterState | undefined;
|
|
348
353
|
smsState?: import(".").SmsState | undefined;
|
|
349
354
|
stepUpState?: import(".").StepUpState | undefined;
|
|
355
|
+
applicationsState?: import(".").ApplicationsState | undefined;
|
|
350
356
|
routes: import("./interfaces").AuthPageRoutes;
|
|
351
357
|
header?: any;
|
|
352
358
|
loaderComponent?: any;
|
package/index.js
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applicationsState = exports.applicationsReducers = exports.applicationsActions = void 0;
|
|
7
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
var _constants = require("../../constants");
|
|
10
|
+
const applicationsState = {
|
|
11
|
+
loading: true,
|
|
12
|
+
fetching: true,
|
|
13
|
+
error: null,
|
|
14
|
+
userApplications: [],
|
|
15
|
+
accountApplications: []
|
|
16
|
+
};
|
|
17
|
+
exports.applicationsState = applicationsState;
|
|
18
|
+
const reducers = {
|
|
19
|
+
setApplicationsState: (0, _utils.typeReducerForKey)('applicationsState')
|
|
20
|
+
};
|
|
21
|
+
exports.applicationsReducers = reducers;
|
|
22
|
+
const actions = {
|
|
23
|
+
loadUserApplications: (0, _toolkit.createAction)(`${_constants.authStoreName}/loadUserApplications`),
|
|
24
|
+
loadAccountApplications: (0, _toolkit.createAction)(`${_constants.authStoreName}/loadAccountApplications`),
|
|
25
|
+
assignUserToApps: (0, _toolkit.createAction)(`${_constants.authStoreName}/assignUserToApps`, payload => ({
|
|
26
|
+
payload
|
|
27
|
+
})),
|
|
28
|
+
unassignUserFromApps: (0, _toolkit.createAction)(`${_constants.authStoreName}/unassignUserFromApps`, payload => ({
|
|
29
|
+
payload
|
|
30
|
+
}))
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* To be used for actions types after dispatch, and should contains
|
|
35
|
+
* the reducers and actions as standalone function
|
|
36
|
+
*/
|
|
37
|
+
exports.applicationsActions = actions;
|
|
38
|
+
// noinspection JSUnusedLocalSymbols
|
|
39
|
+
/**
|
|
40
|
+
* if you see error in matcher that's mean the DispatchAction does not
|
|
41
|
+
* contains the same functions in reducers and actions
|
|
42
|
+
*/
|
|
43
|
+
const Matcher = {};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.applicationsSaga = applicationsSaga;
|
|
8
|
+
exports.assignNewUserToApps = assignNewUserToApps;
|
|
9
|
+
exports.assignUserToApps = assignUserToApps;
|
|
10
|
+
exports.loadAccountApplications = loadAccountApplications;
|
|
11
|
+
exports.loadMultipleUsersApplications = loadMultipleUsersApplications;
|
|
12
|
+
exports.loadUserApplications = loadUserApplications;
|
|
13
|
+
exports.mapUsersWithApplicationData = mapUsersWithApplicationData;
|
|
14
|
+
exports.unassignUserFromApps = unassignUserFromApps;
|
|
15
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
|
+
var _restApi = require("@frontegg/rest-api");
|
|
17
|
+
var _effects = require("redux-saga/effects");
|
|
18
|
+
var _utils = require("../../utils");
|
|
19
|
+
var _reducer = require("../reducer");
|
|
20
|
+
var _helpers = require("../../helpers");
|
|
21
|
+
var _getFlattenAppIds = require("./utils/getFlattenAppIds");
|
|
22
|
+
function* loadUserApplications() {
|
|
23
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
24
|
+
loading: true,
|
|
25
|
+
fetching: true
|
|
26
|
+
}));
|
|
27
|
+
try {
|
|
28
|
+
const userId = yield (0, _effects.select)(({
|
|
29
|
+
auth
|
|
30
|
+
}) => {
|
|
31
|
+
var _auth$user;
|
|
32
|
+
return auth == null ? void 0 : (_auth$user = auth.user) == null ? void 0 : _auth$user.id;
|
|
33
|
+
});
|
|
34
|
+
const appIds = yield (0, _effects.call)(_restApi.api.applications.getUserApplicationsId, {
|
|
35
|
+
userId
|
|
36
|
+
});
|
|
37
|
+
const userApplications = yield (0, _effects.call)(_restApi.api.applications.getApplicationsData, {
|
|
38
|
+
appIds
|
|
39
|
+
});
|
|
40
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
41
|
+
userApplications,
|
|
42
|
+
fetching: false,
|
|
43
|
+
loading: false
|
|
44
|
+
}));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
47
|
+
loading: false,
|
|
48
|
+
fetching: false,
|
|
49
|
+
error: (0, _utils.errorHandler)(e)
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function* loadAccountApplications() {
|
|
54
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
55
|
+
loading: true,
|
|
56
|
+
fetching: true
|
|
57
|
+
}));
|
|
58
|
+
try {
|
|
59
|
+
const tenantAppIds = yield (0, _effects.call)(_restApi.api.applications.getTenantsApplications);
|
|
60
|
+
const appIds = (0, _getFlattenAppIds.getFlattenAppIds)(tenantAppIds);
|
|
61
|
+
const accountApplications = yield (0, _effects.call)(_restApi.api.applications.getApplicationsData, {
|
|
62
|
+
appIds
|
|
63
|
+
});
|
|
64
|
+
const usersOfApplications = yield (0, _effects.call)(_restApi.api.applications.getUsersOfApplications, {
|
|
65
|
+
appIds
|
|
66
|
+
});
|
|
67
|
+
const accountApplicationsWithUsers = accountApplications.map(app => {
|
|
68
|
+
var _usersOfApplications$;
|
|
69
|
+
return (0, _extends2.default)({}, app, {
|
|
70
|
+
userIds: (_usersOfApplications$ = usersOfApplications.find(u => u.appId === app.id)) == null ? void 0 : _usersOfApplications$.userIds
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
74
|
+
accountApplications: accountApplicationsWithUsers,
|
|
75
|
+
fetching: false,
|
|
76
|
+
loading: false
|
|
77
|
+
}));
|
|
78
|
+
} catch (e) {
|
|
79
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
80
|
+
loading: false,
|
|
81
|
+
fetching: false,
|
|
82
|
+
error: (0, _utils.errorHandler)(e)
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function* loadMultipleUsersApplications({
|
|
87
|
+
userIds
|
|
88
|
+
}) {
|
|
89
|
+
try {
|
|
90
|
+
const usersAppIds = yield (0, _effects.call)(_restApi.api.applications.getUsersApplicationsId, {
|
|
91
|
+
userIds
|
|
92
|
+
});
|
|
93
|
+
const appIds = (0, _getFlattenAppIds.getFlattenAppIds)(usersAppIds);
|
|
94
|
+
const accountApplications = yield (0, _effects.call)(_restApi.api.applications.getApplicationsData, {
|
|
95
|
+
appIds
|
|
96
|
+
});
|
|
97
|
+
return userIds.reduce((acc, userId) => {
|
|
98
|
+
var _usersAppIds$find, _userAppIds$map;
|
|
99
|
+
const userAppIds = (_usersAppIds$find = usersAppIds.find(app => app.userId == userId)) == null ? void 0 : _usersAppIds$find.appIds;
|
|
100
|
+
acc[userId] = [...accountApplications.filter(app => app.accessType === _restApi.ApplicationAccessType.FREE_ACCESS), ...((_userAppIds$map = userAppIds == null ? void 0 : userAppIds.map(appId => accountApplications.find(app => appId === app.id))) != null ? _userAppIds$map : [])];
|
|
101
|
+
return acc;
|
|
102
|
+
}, {});
|
|
103
|
+
} catch (e) {
|
|
104
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
105
|
+
error: (0, _utils.errorHandler)(e)
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function* assignUserToApps({
|
|
110
|
+
payload
|
|
111
|
+
}) {
|
|
112
|
+
const {
|
|
113
|
+
userId,
|
|
114
|
+
appIds,
|
|
115
|
+
callback
|
|
116
|
+
} = payload;
|
|
117
|
+
try {
|
|
118
|
+
var _select, _accountApps$filter;
|
|
119
|
+
const tenantId = yield (0, _effects.select)(({
|
|
120
|
+
auth
|
|
121
|
+
}) => {
|
|
122
|
+
var _auth$user2;
|
|
123
|
+
return auth == null ? void 0 : (_auth$user2 = auth.user) == null ? void 0 : _auth$user2.tenantId;
|
|
124
|
+
});
|
|
125
|
+
yield (0, _effects.call)(_restApi.api.applications.assignUserToApplications, {
|
|
126
|
+
userId,
|
|
127
|
+
appIds,
|
|
128
|
+
tenantId
|
|
129
|
+
});
|
|
130
|
+
const accountApps = yield (_select = (0, _effects.select)(({
|
|
131
|
+
auth
|
|
132
|
+
}) => {
|
|
133
|
+
var _auth$applicationsSta;
|
|
134
|
+
return auth == null ? void 0 : (_auth$applicationsSta = auth.applicationsState) == null ? void 0 : _auth$applicationsSta.accountApplications;
|
|
135
|
+
})) != null ? _select : [];
|
|
136
|
+
const users = yield (0, _effects.select)(({
|
|
137
|
+
auth
|
|
138
|
+
}) => {
|
|
139
|
+
var _auth$teamState;
|
|
140
|
+
return auth == null ? void 0 : (_auth$teamState = auth.teamState) == null ? void 0 : _auth$teamState.users;
|
|
141
|
+
});
|
|
142
|
+
const newApps = (_accountApps$filter = accountApps == null ? void 0 : accountApps.filter(app => appIds.includes(app.id))) != null ? _accountApps$filter : [];
|
|
143
|
+
if (newApps != null && newApps.length) {
|
|
144
|
+
yield (0, _effects.put)(_reducer.actions.setTeamState({
|
|
145
|
+
users: users.map(user => {
|
|
146
|
+
var _user$applications;
|
|
147
|
+
return user.id === userId ? (0, _extends2.default)({}, user, {
|
|
148
|
+
applications: [...((_user$applications = user.applications) != null ? _user$applications : []), ...newApps]
|
|
149
|
+
}) : user;
|
|
150
|
+
})
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
callback == null ? void 0 : callback(true);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
156
|
+
error: (0, _utils.errorHandler)(e)
|
|
157
|
+
}));
|
|
158
|
+
callback == null ? void 0 : callback(false);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function* unassignUserFromApps({
|
|
162
|
+
payload
|
|
163
|
+
}) {
|
|
164
|
+
const {
|
|
165
|
+
userId,
|
|
166
|
+
appIds,
|
|
167
|
+
callback
|
|
168
|
+
} = payload;
|
|
169
|
+
try {
|
|
170
|
+
var _users$find;
|
|
171
|
+
const tenantId = yield (0, _effects.select)(({
|
|
172
|
+
auth
|
|
173
|
+
}) => {
|
|
174
|
+
var _auth$user3;
|
|
175
|
+
return auth == null ? void 0 : (_auth$user3 = auth.user) == null ? void 0 : _auth$user3.tenantId;
|
|
176
|
+
});
|
|
177
|
+
yield (0, _effects.call)(_restApi.api.applications.unassignUserFromApplications, {
|
|
178
|
+
userId,
|
|
179
|
+
appIds,
|
|
180
|
+
tenantId
|
|
181
|
+
});
|
|
182
|
+
const users = yield (0, _effects.select)(({
|
|
183
|
+
auth
|
|
184
|
+
}) => {
|
|
185
|
+
var _auth$teamState2;
|
|
186
|
+
return auth == null ? void 0 : (_auth$teamState2 = auth.teamState) == null ? void 0 : _auth$teamState2.users;
|
|
187
|
+
});
|
|
188
|
+
const userApps = (_users$find = users.find(user => user.id === userId)) == null ? void 0 : _users$find.applications;
|
|
189
|
+
if (userApps != null && userApps.length && appIds.length) {
|
|
190
|
+
yield (0, _effects.put)(_reducer.actions.setTeamState({
|
|
191
|
+
users: users.map(user => user.id === userId ? (0, _extends2.default)({}, user, {
|
|
192
|
+
applications: userApps.filter(app => !appIds.includes(app.id))
|
|
193
|
+
}) : user)
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
callback == null ? void 0 : callback(true);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
yield (0, _effects.put)(_reducer.actions.setApplicationsState({
|
|
199
|
+
error: (0, _utils.errorHandler)(e)
|
|
200
|
+
}));
|
|
201
|
+
callback == null ? void 0 : callback(false);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function* assignNewUserToApps({
|
|
205
|
+
appIds,
|
|
206
|
+
user
|
|
207
|
+
}) {
|
|
208
|
+
var _apps$filter;
|
|
209
|
+
const [multiAppsFlag] = yield (0, _effects.call)(_helpers.getFeatureFlags, ['multi-apps-admin-portal']);
|
|
210
|
+
if (!multiAppsFlag) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const apps = yield (0, _effects.select)(({
|
|
214
|
+
auth
|
|
215
|
+
}) => {
|
|
216
|
+
var _auth$applicationsSta2;
|
|
217
|
+
return auth == null ? void 0 : (_auth$applicationsSta2 = auth.applicationsState) == null ? void 0 : _auth$applicationsSta2.accountApplications;
|
|
218
|
+
});
|
|
219
|
+
const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === _restApi.ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
|
|
220
|
+
if (appIds != null && appIds.length) {
|
|
221
|
+
const tenantId = yield (0, _effects.select)(({
|
|
222
|
+
auth
|
|
223
|
+
}) => {
|
|
224
|
+
var _auth$user4;
|
|
225
|
+
return auth == null ? void 0 : (_auth$user4 = auth.user) == null ? void 0 : _auth$user4.tenantId;
|
|
226
|
+
});
|
|
227
|
+
yield (0, _effects.call)(_restApi.api.applications.assignUserToApplications, {
|
|
228
|
+
userId: user.id,
|
|
229
|
+
appIds,
|
|
230
|
+
tenantId
|
|
231
|
+
});
|
|
232
|
+
return appIds.map(appId => {
|
|
233
|
+
var _apps$find;
|
|
234
|
+
return (_apps$find = apps == null ? void 0 : apps.find(app => app.id === appId)) != null ? _apps$find : [];
|
|
235
|
+
}).concat(defaultApps);
|
|
236
|
+
} else {
|
|
237
|
+
return defaultApps;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function* mapUsersWithApplicationData({
|
|
241
|
+
shouldLoadApps,
|
|
242
|
+
users
|
|
243
|
+
}) {
|
|
244
|
+
const [multiAppsFlag] = yield (0, _effects.call)(_helpers.getFeatureFlags, ['multi-apps-admin-portal']);
|
|
245
|
+
if (!multiAppsFlag || !shouldLoadApps) {
|
|
246
|
+
return users;
|
|
247
|
+
}
|
|
248
|
+
const userIds = users.map(user => user.id);
|
|
249
|
+
const userApps = yield (0, _effects.call)(loadMultipleUsersApplications, {
|
|
250
|
+
userIds
|
|
251
|
+
});
|
|
252
|
+
if (!userApps) {
|
|
253
|
+
return users;
|
|
254
|
+
}
|
|
255
|
+
return users.map(user => userApps != null && userApps[user.id] ? (0, _extends2.default)({}, user, {
|
|
256
|
+
applications: userApps[user.id]
|
|
257
|
+
}) : user);
|
|
258
|
+
}
|
|
259
|
+
function* applicationsSaga() {
|
|
260
|
+
yield (0, _effects.takeLeading)(_reducer.actions.loadUserApplications, loadUserApplications);
|
|
261
|
+
yield (0, _effects.takeLeading)(_reducer.actions.loadAccountApplications, loadAccountApplications);
|
|
262
|
+
yield (0, _effects.takeLeading)(_reducer.actions.assignUserToApps, assignUserToApps);
|
|
263
|
+
yield (0, _effects.takeLeading)(_reducer.actions.unassignUserFromApps, unassignUserFromApps);
|
|
264
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFlattenAppIds = void 0;
|
|
7
|
+
const getFlattenAppIds = listWithAppIds => {
|
|
8
|
+
var _listWithAppIds$map$r;
|
|
9
|
+
return (_listWithAppIds$map$r = listWithAppIds.map(({
|
|
10
|
+
appIds
|
|
11
|
+
}) => appIds).reduce((allAppIds, currentAppIds) => {
|
|
12
|
+
currentAppIds == null ? void 0 : currentAppIds.forEach(item => {
|
|
13
|
+
if (allAppIds && !allAppIds.includes(item)) {
|
|
14
|
+
allAppIds.push(item);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return allAppIds;
|
|
18
|
+
}, [])) != null ? _listWithAppIds$map$r : [];
|
|
19
|
+
};
|
|
20
|
+
exports.getFlattenAppIds = getFlattenAppIds;
|