@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
|
@@ -55,6 +55,7 @@ declare const reducers: {
|
|
|
55
55
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
56
56
|
smsState?: import("..").SmsState | undefined;
|
|
57
57
|
stepUpState?: import("..").StepUpState | undefined;
|
|
58
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
58
59
|
routes: import("..").AuthPageRoutes;
|
|
59
60
|
header?: any;
|
|
60
61
|
loaderComponent?: any;
|
|
@@ -106,6 +107,7 @@ declare const reducers: {
|
|
|
106
107
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
107
108
|
smsState?: import("..").SmsState | undefined;
|
|
108
109
|
stepUpState?: import("..").StepUpState | undefined;
|
|
110
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
109
111
|
routes: import("..").AuthPageRoutes;
|
|
110
112
|
header?: any;
|
|
111
113
|
loaderComponent?: any;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -164,6 +166,7 @@ declare const reducers: {
|
|
|
164
166
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
165
167
|
smsState?: import("..").SmsState | undefined;
|
|
166
168
|
stepUpState?: import("..").StepUpState | undefined;
|
|
169
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
167
170
|
routes: import("..").AuthPageRoutes;
|
|
168
171
|
header?: any;
|
|
169
172
|
loaderComponent?: any;
|
|
@@ -73,6 +73,7 @@ declare const reducers: {
|
|
|
73
73
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
74
74
|
smsState?: import("..").SmsState | undefined;
|
|
75
75
|
stepUpState?: import("..").StepUpState | undefined;
|
|
76
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
76
77
|
routes: import("..").AuthPageRoutes;
|
|
77
78
|
header?: any;
|
|
78
79
|
loaderComponent?: any;
|
|
@@ -124,6 +125,7 @@ declare const reducers: {
|
|
|
124
125
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
125
126
|
smsState?: import("..").SmsState | undefined;
|
|
126
127
|
stepUpState?: import("..").StepUpState | undefined;
|
|
128
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
127
129
|
routes: import("..").AuthPageRoutes;
|
|
128
130
|
header?: any;
|
|
129
131
|
loaderComponent?: any;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ApplicationsState, UserAppsAssignmentPayload } from './interfaces';
|
|
2
|
+
import { WithCallback } from '../../interfaces';
|
|
3
|
+
declare const applicationsState: ApplicationsState;
|
|
4
|
+
declare const reducers: {
|
|
5
|
+
setApplicationsState: {
|
|
6
|
+
prepare: (payload: Partial<ApplicationsState>) => {
|
|
7
|
+
payload: Partial<ApplicationsState>;
|
|
8
|
+
};
|
|
9
|
+
reducer: (state: import("..").AuthState, { payload }: {
|
|
10
|
+
payload: Partial<ApplicationsState>;
|
|
11
|
+
type: string;
|
|
12
|
+
}) => {
|
|
13
|
+
onRedirectTo: (path: string, opts?: import("@frontegg/rest-api").RedirectOptions | undefined) => void;
|
|
14
|
+
error?: any;
|
|
15
|
+
isAuthenticated: boolean;
|
|
16
|
+
userIp?: string | undefined;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
keepSessionAlive?: boolean | undefined;
|
|
19
|
+
socialLoginOptions?: {
|
|
20
|
+
promptConsent?: boolean | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
user?: import("..").User | null | undefined;
|
|
23
|
+
isSSOAuth: boolean;
|
|
24
|
+
ssoACS?: string | undefined;
|
|
25
|
+
includeQueryParam?: boolean | undefined;
|
|
26
|
+
loginState: import("..").LoginState;
|
|
27
|
+
activateState: import("..").ActivateAccountState;
|
|
28
|
+
acceptInvitationState: import("..").AcceptInvitationState;
|
|
29
|
+
forgotPasswordState: import("..").ForgotPasswordState;
|
|
30
|
+
resetPhoneNumberState: import("..").ResetPhoneNumberState;
|
|
31
|
+
ssoState: import("..").SSOState;
|
|
32
|
+
profileState: import("..").ProfileState;
|
|
33
|
+
mfaState: import("..").MFAState;
|
|
34
|
+
teamState: import("..").TeamState;
|
|
35
|
+
groupsState: import("..").GroupsState;
|
|
36
|
+
groupsDialogsState: import("..").GroupsDialogsState;
|
|
37
|
+
socialLoginState: import("..").SocialLoginState;
|
|
38
|
+
signUpState: import("..").SignUpState;
|
|
39
|
+
apiTokensState: import("..").ApiTokensState;
|
|
40
|
+
securityPolicyState: import("..").SecurityPolicyState;
|
|
41
|
+
restrictionsState: import("..").RestrictionsState;
|
|
42
|
+
provisioningState: import("..").ProvisioningState;
|
|
43
|
+
accountSettingsState: import("..").AccountSettingsState;
|
|
44
|
+
tenantsState: import("..").TenantsState;
|
|
45
|
+
rolesState: import("..").RolesState;
|
|
46
|
+
sessionsState: import("..").SessionsState;
|
|
47
|
+
hostedLoginBox?: boolean | undefined;
|
|
48
|
+
disableSilentRefresh?: boolean | undefined;
|
|
49
|
+
sessionsPolicyState: import("..").SessionsPolicyState;
|
|
50
|
+
impersonateState?: import("..").ImpersonateState | undefined;
|
|
51
|
+
passkeysState?: import("..").PasskeysState | undefined;
|
|
52
|
+
customLoginState?: import("..").CustomLoginState | undefined;
|
|
53
|
+
allAccountsState?: import("..").IAllAccountsState | undefined;
|
|
54
|
+
allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
|
|
55
|
+
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
56
|
+
smsState?: import("..").SmsState | undefined;
|
|
57
|
+
stepUpState?: import("..").StepUpState | undefined;
|
|
58
|
+
applicationsState?: ApplicationsState | undefined;
|
|
59
|
+
routes: import("..").AuthPageRoutes;
|
|
60
|
+
header?: any;
|
|
61
|
+
loaderComponent?: any;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
declare const actions: {
|
|
66
|
+
loadUserApplications: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
67
|
+
loadAccountApplications: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
68
|
+
assignUserToApps: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>], WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>, string, never, never>;
|
|
69
|
+
unassignUserFromApps: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>], WithCallback<Pick<import("@frontegg/rest-api").IAssignUserToApplicationsBody, "userId" | "appIds">, boolean>, string, never, never>;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* To be used for actions types after dispatch, and should contains
|
|
73
|
+
* the reducers and actions as standalone function
|
|
74
|
+
*/
|
|
75
|
+
declare type DispatchedActions = {
|
|
76
|
+
setApplicationsState: (state: Partial<ApplicationsState>) => void;
|
|
77
|
+
loadUserApplications: () => void;
|
|
78
|
+
loadAccountApplications: () => void;
|
|
79
|
+
assignUserToApps: (payload: WithCallback<UserAppsAssignmentPayload>) => void;
|
|
80
|
+
unassignUserFromApps: (payload: WithCallback<UserAppsAssignmentPayload>) => void;
|
|
81
|
+
};
|
|
82
|
+
export declare type ApplicationsActions = DispatchedActions;
|
|
83
|
+
export { applicationsState, reducers as applicationsReducers, actions as applicationsActions };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { typeReducerForKey } from '../utils';
|
|
3
|
+
import { authStoreName } from '../../constants';
|
|
4
|
+
const applicationsState = {
|
|
5
|
+
loading: true,
|
|
6
|
+
fetching: true,
|
|
7
|
+
error: null,
|
|
8
|
+
userApplications: [],
|
|
9
|
+
accountApplications: []
|
|
10
|
+
};
|
|
11
|
+
const reducers = {
|
|
12
|
+
setApplicationsState: typeReducerForKey('applicationsState')
|
|
13
|
+
};
|
|
14
|
+
const actions = {
|
|
15
|
+
loadUserApplications: createAction(`${authStoreName}/loadUserApplications`),
|
|
16
|
+
loadAccountApplications: createAction(`${authStoreName}/loadAccountApplications`),
|
|
17
|
+
assignUserToApps: createAction(`${authStoreName}/assignUserToApps`, payload => ({
|
|
18
|
+
payload
|
|
19
|
+
})),
|
|
20
|
+
unassignUserFromApps: createAction(`${authStoreName}/unassignUserFromApps`, payload => ({
|
|
21
|
+
payload
|
|
22
|
+
}))
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* To be used for actions types after dispatch, and should contains
|
|
27
|
+
* the reducers and actions as standalone function
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
// noinspection JSUnusedLocalSymbols
|
|
31
|
+
/**
|
|
32
|
+
* if you see error in matcher that's mean the DispatchAction does not
|
|
33
|
+
* contains the same functions in reducers and actions
|
|
34
|
+
*/
|
|
35
|
+
const Matcher = {};
|
|
36
|
+
export { applicationsState, reducers as applicationsReducers, actions as applicationsActions };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IApplicationsResponse, IAssignUserToApplicationsBody } from '@frontegg/rest-api';
|
|
2
|
+
export interface ApplicationsState {
|
|
3
|
+
error?: string | null;
|
|
4
|
+
fetching?: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
saving?: boolean;
|
|
7
|
+
userApplications?: IApplicationsResponse[];
|
|
8
|
+
accountApplications?: (IApplicationsResponse & {
|
|
9
|
+
userIds?: string[];
|
|
10
|
+
})[];
|
|
11
|
+
}
|
|
12
|
+
export declare type UserAppsAssignmentPayload = Pick<IAssignUserToApplicationsBody, 'userId' | 'appIds'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IApplicationsResponse, IUsersOfApplicationsResponse, ITenantApplicationsResponse, ITeamUser, IUsersApplicationsIdsResponse } from '@frontegg/rest-api';
|
|
2
|
+
import { ApplicationsState, UserAppsAssignmentPayload } from './interfaces';
|
|
3
|
+
import { WithCallback } from '../../interfaces';
|
|
4
|
+
import { PayloadAction } from '@reduxjs/toolkit';
|
|
5
|
+
import { ITeamStateUser } from '../TeamState/interfaces';
|
|
6
|
+
export declare function loadUserApplications(): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").CallEffect<string[]> | import("redux-saga/effects").PutEffect<{
|
|
7
|
+
payload: Partial<ApplicationsState>;
|
|
8
|
+
type: string;
|
|
9
|
+
}> | import("redux-saga/effects").CallEffect<IApplicationsResponse[]>, void, string & string[] & IApplicationsResponse[]>;
|
|
10
|
+
export declare function loadAccountApplications(): Generator<import("redux-saga/effects").PutEffect<{
|
|
11
|
+
payload: Partial<ApplicationsState>;
|
|
12
|
+
type: string;
|
|
13
|
+
}> | import("redux-saga/effects").CallEffect<IApplicationsResponse[]> | import("redux-saga/effects").CallEffect<ITenantApplicationsResponse[]> | import("redux-saga/effects").CallEffect<IUsersOfApplicationsResponse[]>, void, ITenantApplicationsResponse[] & IApplicationsResponse[] & IUsersOfApplicationsResponse[]>;
|
|
14
|
+
export declare function loadMultipleUsersApplications({ userIds }: {
|
|
15
|
+
userIds: string[];
|
|
16
|
+
}): Generator<import("redux-saga/effects").PutEffect<{
|
|
17
|
+
payload: Partial<ApplicationsState>;
|
|
18
|
+
type: string;
|
|
19
|
+
}> | import("redux-saga/effects").CallEffect<IApplicationsResponse[]> | import("redux-saga/effects").CallEffect<IUsersApplicationsIdsResponse[]>, {} | undefined, IUsersApplicationsIdsResponse[] & IApplicationsResponse[]>;
|
|
20
|
+
export declare function assignUserToApps({ payload }: PayloadAction<WithCallback<UserAppsAssignmentPayload>>): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
21
|
+
payload: Partial<import("../TeamState/interfaces").TeamState>;
|
|
22
|
+
type: string;
|
|
23
|
+
}> | import("redux-saga/effects").PutEffect<{
|
|
24
|
+
payload: Partial<ApplicationsState>;
|
|
25
|
+
type: string;
|
|
26
|
+
}>, void, string & (IApplicationsResponse & {
|
|
27
|
+
userIds?: string[] | undefined;
|
|
28
|
+
})[] & ITeamStateUser[]>;
|
|
29
|
+
export declare function unassignUserFromApps({ payload }: PayloadAction<WithCallback<UserAppsAssignmentPayload>>): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").PutEffect<{
|
|
30
|
+
payload: Partial<import("../TeamState/interfaces").TeamState>;
|
|
31
|
+
type: string;
|
|
32
|
+
}> | import("redux-saga/effects").PutEffect<{
|
|
33
|
+
payload: Partial<ApplicationsState>;
|
|
34
|
+
type: string;
|
|
35
|
+
}>, void, string & ITeamStateUser[]>;
|
|
36
|
+
export declare function assignNewUserToApps({ appIds, user }: {
|
|
37
|
+
appIds?: string[];
|
|
38
|
+
user: ITeamUser;
|
|
39
|
+
}): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").CallEffect<void> | import("redux-saga/effects").CallEffect<boolean[]>, ((IApplicationsResponse & {
|
|
40
|
+
userIds?: string[] | undefined;
|
|
41
|
+
}) | never[])[] | undefined, boolean[] & (IApplicationsResponse & {
|
|
42
|
+
userIds?: string[] | undefined;
|
|
43
|
+
})[] & string>;
|
|
44
|
+
export declare function mapUsersWithApplicationData({ shouldLoadApps, users, }: {
|
|
45
|
+
shouldLoadApps?: boolean;
|
|
46
|
+
users: ITeamUser[];
|
|
47
|
+
}): Generator<import("redux-saga/effects").CallEffect<{} | undefined>, ITeamUser[], boolean[] & Record<string, IApplicationsResponse[]>>;
|
|
48
|
+
export declare function applicationsSaga(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { api, ApplicationAccessType } from '@frontegg/rest-api';
|
|
3
|
+
import { call, put, select, takeLeading } from 'redux-saga/effects';
|
|
4
|
+
import { errorHandler } from '../../utils';
|
|
5
|
+
import { actions } from '../reducer';
|
|
6
|
+
import { getFeatureFlags } from '../../helpers';
|
|
7
|
+
import { getFlattenAppIds } from './utils/getFlattenAppIds';
|
|
8
|
+
export function* loadUserApplications() {
|
|
9
|
+
yield put(actions.setApplicationsState({
|
|
10
|
+
loading: true,
|
|
11
|
+
fetching: true
|
|
12
|
+
}));
|
|
13
|
+
try {
|
|
14
|
+
const userId = yield select(({
|
|
15
|
+
auth
|
|
16
|
+
}) => {
|
|
17
|
+
var _auth$user;
|
|
18
|
+
return auth == null ? void 0 : (_auth$user = auth.user) == null ? void 0 : _auth$user.id;
|
|
19
|
+
});
|
|
20
|
+
const appIds = yield call(api.applications.getUserApplicationsId, {
|
|
21
|
+
userId
|
|
22
|
+
});
|
|
23
|
+
const userApplications = yield call(api.applications.getApplicationsData, {
|
|
24
|
+
appIds
|
|
25
|
+
});
|
|
26
|
+
yield put(actions.setApplicationsState({
|
|
27
|
+
userApplications,
|
|
28
|
+
fetching: false,
|
|
29
|
+
loading: false
|
|
30
|
+
}));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
yield put(actions.setApplicationsState({
|
|
33
|
+
loading: false,
|
|
34
|
+
fetching: false,
|
|
35
|
+
error: errorHandler(e)
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function* loadAccountApplications() {
|
|
40
|
+
yield put(actions.setApplicationsState({
|
|
41
|
+
loading: true,
|
|
42
|
+
fetching: true
|
|
43
|
+
}));
|
|
44
|
+
try {
|
|
45
|
+
const tenantAppIds = yield call(api.applications.getTenantsApplications);
|
|
46
|
+
const appIds = getFlattenAppIds(tenantAppIds);
|
|
47
|
+
const accountApplications = yield call(api.applications.getApplicationsData, {
|
|
48
|
+
appIds
|
|
49
|
+
});
|
|
50
|
+
const usersOfApplications = yield call(api.applications.getUsersOfApplications, {
|
|
51
|
+
appIds
|
|
52
|
+
});
|
|
53
|
+
const accountApplicationsWithUsers = accountApplications.map(app => {
|
|
54
|
+
var _usersOfApplications$;
|
|
55
|
+
return _extends({}, app, {
|
|
56
|
+
userIds: (_usersOfApplications$ = usersOfApplications.find(u => u.appId === app.id)) == null ? void 0 : _usersOfApplications$.userIds
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
yield put(actions.setApplicationsState({
|
|
60
|
+
accountApplications: accountApplicationsWithUsers,
|
|
61
|
+
fetching: false,
|
|
62
|
+
loading: false
|
|
63
|
+
}));
|
|
64
|
+
} catch (e) {
|
|
65
|
+
yield put(actions.setApplicationsState({
|
|
66
|
+
loading: false,
|
|
67
|
+
fetching: false,
|
|
68
|
+
error: errorHandler(e)
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function* loadMultipleUsersApplications({
|
|
73
|
+
userIds
|
|
74
|
+
}) {
|
|
75
|
+
try {
|
|
76
|
+
const usersAppIds = yield call(api.applications.getUsersApplicationsId, {
|
|
77
|
+
userIds
|
|
78
|
+
});
|
|
79
|
+
const appIds = getFlattenAppIds(usersAppIds);
|
|
80
|
+
const accountApplications = yield call(api.applications.getApplicationsData, {
|
|
81
|
+
appIds
|
|
82
|
+
});
|
|
83
|
+
return userIds.reduce((acc, userId) => {
|
|
84
|
+
var _usersAppIds$find, _userAppIds$map;
|
|
85
|
+
const userAppIds = (_usersAppIds$find = usersAppIds.find(app => app.userId == userId)) == null ? void 0 : _usersAppIds$find.appIds;
|
|
86
|
+
acc[userId] = [...accountApplications.filter(app => app.accessType === ApplicationAccessType.FREE_ACCESS), ...((_userAppIds$map = userAppIds == null ? void 0 : userAppIds.map(appId => accountApplications.find(app => appId === app.id))) != null ? _userAppIds$map : [])];
|
|
87
|
+
return acc;
|
|
88
|
+
}, {});
|
|
89
|
+
} catch (e) {
|
|
90
|
+
yield put(actions.setApplicationsState({
|
|
91
|
+
error: errorHandler(e)
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function* assignUserToApps({
|
|
96
|
+
payload
|
|
97
|
+
}) {
|
|
98
|
+
const {
|
|
99
|
+
userId,
|
|
100
|
+
appIds,
|
|
101
|
+
callback
|
|
102
|
+
} = payload;
|
|
103
|
+
try {
|
|
104
|
+
var _select, _accountApps$filter;
|
|
105
|
+
const tenantId = yield select(({
|
|
106
|
+
auth
|
|
107
|
+
}) => {
|
|
108
|
+
var _auth$user2;
|
|
109
|
+
return auth == null ? void 0 : (_auth$user2 = auth.user) == null ? void 0 : _auth$user2.tenantId;
|
|
110
|
+
});
|
|
111
|
+
yield call(api.applications.assignUserToApplications, {
|
|
112
|
+
userId,
|
|
113
|
+
appIds,
|
|
114
|
+
tenantId
|
|
115
|
+
});
|
|
116
|
+
const accountApps = yield (_select = select(({
|
|
117
|
+
auth
|
|
118
|
+
}) => {
|
|
119
|
+
var _auth$applicationsSta;
|
|
120
|
+
return auth == null ? void 0 : (_auth$applicationsSta = auth.applicationsState) == null ? void 0 : _auth$applicationsSta.accountApplications;
|
|
121
|
+
})) != null ? _select : [];
|
|
122
|
+
const users = yield select(({
|
|
123
|
+
auth
|
|
124
|
+
}) => {
|
|
125
|
+
var _auth$teamState;
|
|
126
|
+
return auth == null ? void 0 : (_auth$teamState = auth.teamState) == null ? void 0 : _auth$teamState.users;
|
|
127
|
+
});
|
|
128
|
+
const newApps = (_accountApps$filter = accountApps == null ? void 0 : accountApps.filter(app => appIds.includes(app.id))) != null ? _accountApps$filter : [];
|
|
129
|
+
if (newApps != null && newApps.length) {
|
|
130
|
+
yield put(actions.setTeamState({
|
|
131
|
+
users: users.map(user => {
|
|
132
|
+
var _user$applications;
|
|
133
|
+
return user.id === userId ? _extends({}, user, {
|
|
134
|
+
applications: [...((_user$applications = user.applications) != null ? _user$applications : []), ...newApps]
|
|
135
|
+
}) : user;
|
|
136
|
+
})
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
callback == null ? void 0 : callback(true);
|
|
140
|
+
} catch (e) {
|
|
141
|
+
yield put(actions.setApplicationsState({
|
|
142
|
+
error: errorHandler(e)
|
|
143
|
+
}));
|
|
144
|
+
callback == null ? void 0 : callback(false);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export function* unassignUserFromApps({
|
|
148
|
+
payload
|
|
149
|
+
}) {
|
|
150
|
+
const {
|
|
151
|
+
userId,
|
|
152
|
+
appIds,
|
|
153
|
+
callback
|
|
154
|
+
} = payload;
|
|
155
|
+
try {
|
|
156
|
+
var _users$find;
|
|
157
|
+
const tenantId = yield select(({
|
|
158
|
+
auth
|
|
159
|
+
}) => {
|
|
160
|
+
var _auth$user3;
|
|
161
|
+
return auth == null ? void 0 : (_auth$user3 = auth.user) == null ? void 0 : _auth$user3.tenantId;
|
|
162
|
+
});
|
|
163
|
+
yield call(api.applications.unassignUserFromApplications, {
|
|
164
|
+
userId,
|
|
165
|
+
appIds,
|
|
166
|
+
tenantId
|
|
167
|
+
});
|
|
168
|
+
const users = yield select(({
|
|
169
|
+
auth
|
|
170
|
+
}) => {
|
|
171
|
+
var _auth$teamState2;
|
|
172
|
+
return auth == null ? void 0 : (_auth$teamState2 = auth.teamState) == null ? void 0 : _auth$teamState2.users;
|
|
173
|
+
});
|
|
174
|
+
const userApps = (_users$find = users.find(user => user.id === userId)) == null ? void 0 : _users$find.applications;
|
|
175
|
+
if (userApps != null && userApps.length && appIds.length) {
|
|
176
|
+
yield put(actions.setTeamState({
|
|
177
|
+
users: users.map(user => user.id === userId ? _extends({}, user, {
|
|
178
|
+
applications: userApps.filter(app => !appIds.includes(app.id))
|
|
179
|
+
}) : user)
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
callback == null ? void 0 : callback(true);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
yield put(actions.setApplicationsState({
|
|
185
|
+
error: errorHandler(e)
|
|
186
|
+
}));
|
|
187
|
+
callback == null ? void 0 : callback(false);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
export function* assignNewUserToApps({
|
|
191
|
+
appIds,
|
|
192
|
+
user
|
|
193
|
+
}) {
|
|
194
|
+
var _apps$filter;
|
|
195
|
+
const [multiAppsFlag] = yield call(getFeatureFlags, ['multi-apps-admin-portal']);
|
|
196
|
+
if (!multiAppsFlag) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const apps = yield select(({
|
|
200
|
+
auth
|
|
201
|
+
}) => {
|
|
202
|
+
var _auth$applicationsSta2;
|
|
203
|
+
return auth == null ? void 0 : (_auth$applicationsSta2 = auth.applicationsState) == null ? void 0 : _auth$applicationsSta2.accountApplications;
|
|
204
|
+
});
|
|
205
|
+
const defaultApps = (_apps$filter = apps == null ? void 0 : apps.filter(app => app.accessType === ApplicationAccessType.FREE_ACCESS)) != null ? _apps$filter : [];
|
|
206
|
+
if (appIds != null && appIds.length) {
|
|
207
|
+
const tenantId = yield select(({
|
|
208
|
+
auth
|
|
209
|
+
}) => {
|
|
210
|
+
var _auth$user4;
|
|
211
|
+
return auth == null ? void 0 : (_auth$user4 = auth.user) == null ? void 0 : _auth$user4.tenantId;
|
|
212
|
+
});
|
|
213
|
+
yield call(api.applications.assignUserToApplications, {
|
|
214
|
+
userId: user.id,
|
|
215
|
+
appIds,
|
|
216
|
+
tenantId
|
|
217
|
+
});
|
|
218
|
+
return appIds.map(appId => {
|
|
219
|
+
var _apps$find;
|
|
220
|
+
return (_apps$find = apps == null ? void 0 : apps.find(app => app.id === appId)) != null ? _apps$find : [];
|
|
221
|
+
}).concat(defaultApps);
|
|
222
|
+
} else {
|
|
223
|
+
return defaultApps;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
export function* mapUsersWithApplicationData({
|
|
227
|
+
shouldLoadApps,
|
|
228
|
+
users
|
|
229
|
+
}) {
|
|
230
|
+
const [multiAppsFlag] = yield call(getFeatureFlags, ['multi-apps-admin-portal']);
|
|
231
|
+
if (!multiAppsFlag || !shouldLoadApps) {
|
|
232
|
+
return users;
|
|
233
|
+
}
|
|
234
|
+
const userIds = users.map(user => user.id);
|
|
235
|
+
const userApps = yield call(loadMultipleUsersApplications, {
|
|
236
|
+
userIds
|
|
237
|
+
});
|
|
238
|
+
if (!userApps) {
|
|
239
|
+
return users;
|
|
240
|
+
}
|
|
241
|
+
return users.map(user => userApps != null && userApps[user.id] ? _extends({}, user, {
|
|
242
|
+
applications: userApps[user.id]
|
|
243
|
+
}) : user);
|
|
244
|
+
}
|
|
245
|
+
export function* applicationsSaga() {
|
|
246
|
+
yield takeLeading(actions.loadUserApplications, loadUserApplications);
|
|
247
|
+
yield takeLeading(actions.loadAccountApplications, loadAccountApplications);
|
|
248
|
+
yield takeLeading(actions.assignUserToApps, assignUserToApps);
|
|
249
|
+
yield takeLeading(actions.unassignUserFromApps, unassignUserFromApps);
|
|
250
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const getFlattenAppIds = listWithAppIds => {
|
|
2
|
+
var _listWithAppIds$map$r;
|
|
3
|
+
return (_listWithAppIds$map$r = listWithAppIds.map(({
|
|
4
|
+
appIds
|
|
5
|
+
}) => appIds).reduce((allAppIds, currentAppIds) => {
|
|
6
|
+
currentAppIds == null ? void 0 : currentAppIds.forEach(item => {
|
|
7
|
+
if (allAppIds && !allAppIds.includes(item)) {
|
|
8
|
+
allAppIds.push(item);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return allAppIds;
|
|
12
|
+
}, [])) != null ? _listWithAppIds$map$r : [];
|
|
13
|
+
};
|
|
@@ -55,6 +55,7 @@ declare const reducers: {
|
|
|
55
55
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
56
56
|
smsState?: import("..").SmsState | undefined;
|
|
57
57
|
stepUpState?: import("..").StepUpState | undefined;
|
|
58
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
58
59
|
routes: import("..").AuthPageRoutes;
|
|
59
60
|
header?: any;
|
|
60
61
|
loaderComponent?: any;
|
|
@@ -106,6 +107,7 @@ declare const reducers: {
|
|
|
106
107
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
107
108
|
smsState?: import("..").SmsState | undefined;
|
|
108
109
|
stepUpState?: import("..").StepUpState | undefined;
|
|
110
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
109
111
|
routes: import("..").AuthPageRoutes;
|
|
110
112
|
header?: any;
|
|
111
113
|
loaderComponent?: any;
|
|
@@ -55,6 +55,7 @@ declare const reducers: {
|
|
|
55
55
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
56
56
|
smsState?: import("..").SmsState | undefined;
|
|
57
57
|
stepUpState?: import("..").StepUpState | undefined;
|
|
58
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
58
59
|
routes: import("..").AuthPageRoutes;
|
|
59
60
|
header?: any;
|
|
60
61
|
loaderComponent?: any;
|
|
@@ -106,6 +107,7 @@ declare const reducers: {
|
|
|
106
107
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
107
108
|
smsState?: import("..").SmsState | undefined;
|
|
108
109
|
stepUpState?: import("..").StepUpState | undefined;
|
|
110
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
109
111
|
routes: import("..").AuthPageRoutes;
|
|
110
112
|
header?: any;
|
|
111
113
|
loaderComponent?: any;
|
|
@@ -54,6 +54,7 @@ declare const reducers: {
|
|
|
54
54
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
55
55
|
smsState?: import("..").SmsState | undefined;
|
|
56
56
|
stepUpState?: import("..").StepUpState | undefined;
|
|
57
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
57
58
|
routes: import("..").AuthPageRoutes;
|
|
58
59
|
header?: any;
|
|
59
60
|
loaderComponent?: any;
|
|
@@ -105,6 +106,7 @@ declare const reducers: {
|
|
|
105
106
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
106
107
|
smsState?: import("..").SmsState | undefined;
|
|
107
108
|
stepUpState?: import("..").StepUpState | undefined;
|
|
109
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
108
110
|
routes: import("..").AuthPageRoutes;
|
|
109
111
|
header?: any;
|
|
110
112
|
loaderComponent?: any;
|
|
@@ -155,6 +157,7 @@ declare const reducers: {
|
|
|
155
157
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
156
158
|
smsState?: import("..").SmsState | undefined;
|
|
157
159
|
stepUpState?: import("..").StepUpState | undefined;
|
|
160
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
158
161
|
routes: import("..").AuthPageRoutes;
|
|
159
162
|
header?: any;
|
|
160
163
|
loaderComponent?: any;
|
|
@@ -205,6 +208,7 @@ declare const reducers: {
|
|
|
205
208
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
206
209
|
smsState?: import("..").SmsState | undefined;
|
|
207
210
|
stepUpState?: import("..").StepUpState | undefined;
|
|
211
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
208
212
|
routes: import("..").AuthPageRoutes;
|
|
209
213
|
header?: any;
|
|
210
214
|
loaderComponent?: any;
|
|
@@ -262,6 +266,7 @@ declare const reducers: {
|
|
|
262
266
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
263
267
|
smsState?: import("..").SmsState | undefined;
|
|
264
268
|
stepUpState?: import("..").StepUpState | undefined;
|
|
269
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
265
270
|
routes: import("..").AuthPageRoutes;
|
|
266
271
|
header?: any;
|
|
267
272
|
loaderComponent?: any;
|
|
@@ -313,6 +318,7 @@ declare const reducers: {
|
|
|
313
318
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
314
319
|
smsState?: import("..").SmsState | undefined;
|
|
315
320
|
stepUpState?: import("..").StepUpState | undefined;
|
|
321
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
316
322
|
routes: import("..").AuthPageRoutes;
|
|
317
323
|
header?: any;
|
|
318
324
|
loaderComponent?: any;
|
|
@@ -391,6 +397,7 @@ declare const reducers: {
|
|
|
391
397
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
392
398
|
smsState?: import("..").SmsState | undefined;
|
|
393
399
|
stepUpState?: import("..").StepUpState | undefined;
|
|
400
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
394
401
|
routes: import("..").AuthPageRoutes;
|
|
395
402
|
header?: any;
|
|
396
403
|
loaderComponent?: any;
|
|
@@ -442,6 +449,7 @@ declare const reducers: {
|
|
|
442
449
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
443
450
|
smsState?: import("..").SmsState | undefined;
|
|
444
451
|
stepUpState?: import("..").StepUpState | undefined;
|
|
452
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
445
453
|
routes: import("..").AuthPageRoutes;
|
|
446
454
|
header?: any;
|
|
447
455
|
loaderComponent?: any;
|
|
@@ -492,6 +500,7 @@ declare const reducers: {
|
|
|
492
500
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
493
501
|
smsState?: import("..").SmsState | undefined;
|
|
494
502
|
stepUpState?: import("..").StepUpState | undefined;
|
|
503
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
495
504
|
routes: import("..").AuthPageRoutes;
|
|
496
505
|
header?: any;
|
|
497
506
|
loaderComponent?: any;
|
|
@@ -542,6 +551,7 @@ declare const reducers: {
|
|
|
542
551
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
543
552
|
smsState?: import("..").SmsState | undefined;
|
|
544
553
|
stepUpState?: import("..").StepUpState | undefined;
|
|
554
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
545
555
|
routes: import("..").AuthPageRoutes;
|
|
546
556
|
header?: any;
|
|
547
557
|
loaderComponent?: any;
|
|
@@ -599,6 +609,7 @@ declare const reducers: {
|
|
|
599
609
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
600
610
|
smsState?: import("..").SmsState | undefined;
|
|
601
611
|
stepUpState?: import("..").StepUpState | undefined;
|
|
612
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
602
613
|
routes: import("..").AuthPageRoutes;
|
|
603
614
|
header?: any;
|
|
604
615
|
loaderComponent?: any;
|
|
@@ -650,6 +661,7 @@ declare const reducers: {
|
|
|
650
661
|
securityCenterState?: import("..").SecurityCenterState | undefined;
|
|
651
662
|
smsState?: import("..").SmsState | undefined;
|
|
652
663
|
stepUpState?: import("..").StepUpState | undefined;
|
|
664
|
+
applicationsState?: import("..").ApplicationsState | undefined;
|
|
653
665
|
routes: import("..").AuthPageRoutes;
|
|
654
666
|
header?: any;
|
|
655
667
|
loaderComponent?: any;
|