@frontegg/redux-store 7.15.0 → 7.16.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/actions.d.ts +2 -1
- package/auth/AcceptInvitationState/actions.js +26 -1
- package/auth/ActivateAccountState/actions.d.ts +2 -1
- package/auth/ActivateAccountState/actions.js +102 -46
- package/auth/ActivateAccountState/interfaces.d.ts +3 -0
- package/auth/LoginState/consts.js +2 -0
- package/auth/interfaces.d.ts +8 -0
- package/index.js +1 -1
- package/mocks/auth-mocks/acceptInvitationActions.mocks.d.ts +1 -0
- package/mocks/auth-mocks/activateAccountActions.mocks.d.ts +1 -0
- package/node/auth/AcceptInvitationState/actions.js +26 -1
- package/node/auth/ActivateAccountState/actions.js +102 -46
- package/node/auth/LoginState/consts.js +2 -0
- package/node/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FronteggState, RestApi, SharedActions } from '../../interfaces';
|
|
2
2
|
import { AcceptInvitationState } from './interfaces';
|
|
3
|
-
import { IAcceptInvitation } from '@frontegg/rest-api';
|
|
3
|
+
import { IAcceptInvitation, IAcceptInvitationWithOTC } from '@frontegg/rest-api';
|
|
4
4
|
declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
|
|
5
5
|
setAcceptInvitationState: (state: Partial<AcceptInvitationState>) => void;
|
|
6
6
|
resetAcceptInvitationState: () => void;
|
|
7
7
|
acceptInvitation: (payload: IAcceptInvitation) => Promise<void>;
|
|
8
|
+
acceptInvitationWithOTC: (payload: IAcceptInvitationWithOTC) => Promise<void>;
|
|
8
9
|
};
|
|
9
10
|
export default _default;
|
|
@@ -33,9 +33,34 @@ export default ((store, api, sharedActions) => {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
+
const acceptInvitationWithOTC = async payload => {
|
|
37
|
+
if (!payload.token || !payload.userId || !payload.code) {
|
|
38
|
+
setAcceptInvitationState({
|
|
39
|
+
error: undefined,
|
|
40
|
+
step: AcceptInvitationStep.invalid
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
setAcceptInvitationState({
|
|
46
|
+
error: undefined,
|
|
47
|
+
step: AcceptInvitationStep.pending
|
|
48
|
+
});
|
|
49
|
+
await api.auth.acceptInvitationWithOTC(payload);
|
|
50
|
+
setAcceptInvitationState({
|
|
51
|
+
step: AcceptInvitationStep.success
|
|
52
|
+
});
|
|
53
|
+
} catch (e) {
|
|
54
|
+
setAcceptInvitationState({
|
|
55
|
+
step: AcceptInvitationStep.failed,
|
|
56
|
+
error: errorHandler(e)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
36
60
|
return {
|
|
37
61
|
setAcceptInvitationState,
|
|
38
62
|
resetAcceptInvitationState,
|
|
39
|
-
acceptInvitation
|
|
63
|
+
acceptInvitation,
|
|
64
|
+
acceptInvitationWithOTC
|
|
40
65
|
};
|
|
41
66
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FronteggState, WithCallback, SharedActions, RestApi } from '../../interfaces';
|
|
2
2
|
import { IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse, IResendActivationEmail } from '@frontegg/rest-api';
|
|
3
|
-
import { ActivateAccountState, IActivateAccountPayload, IPreActivateAccount } from './interfaces';
|
|
3
|
+
import { ActivateAccountState, IActivateAccountPayload, IActivateAccountWithOTCPayload, IPreActivateAccount } from './interfaces';
|
|
4
4
|
declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
|
|
5
5
|
setActivateState: (state: Partial<ActivateAccountState>) => void;
|
|
6
6
|
resetActivateState: () => void;
|
|
@@ -9,5 +9,6 @@ declare const _default: (store: FronteggState, api: RestApi, sharedActions: Shar
|
|
|
9
9
|
preActivateAccount: (payload: IPreActivateAccount) => Promise<void>;
|
|
10
10
|
getActivateAccountStrategy: (payload: WithCallback<IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse>) => Promise<void>;
|
|
11
11
|
resendActivationEmail: (payload: WithCallback<IResendActivationEmail>) => Promise<void>;
|
|
12
|
+
activateAccountWithCode: (_payload: WithCallback<IActivateAccountWithOTCPayload>) => Promise<void>;
|
|
12
13
|
};
|
|
13
14
|
export default _default;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["
|
|
4
|
-
_excluded2 = ["
|
|
5
|
-
_excluded3 = ["
|
|
6
|
-
_excluded4 = ["callback"]
|
|
3
|
+
const _excluded = ["user"],
|
|
4
|
+
_excluded2 = ["callback", "events"],
|
|
5
|
+
_excluded3 = ["user"],
|
|
6
|
+
_excluded4 = ["callback", "events"],
|
|
7
|
+
_excluded5 = ["user"],
|
|
8
|
+
_excluded6 = ["callback"],
|
|
9
|
+
_excluded7 = ["callback"];
|
|
7
10
|
import { initialState } from './state';
|
|
8
11
|
import { ContextHolder } from '@frontegg/rest-api';
|
|
9
12
|
import { errorHandler, delay, deepResetState } from '../../helpers';
|
|
@@ -59,12 +62,61 @@ export default ((store, api, sharedActions) => {
|
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
64
|
};
|
|
65
|
+
const handleActivationResponse = async ({
|
|
66
|
+
loginResponse,
|
|
67
|
+
events,
|
|
68
|
+
onRedirectTo,
|
|
69
|
+
routes
|
|
70
|
+
}) => {
|
|
71
|
+
const {
|
|
72
|
+
user
|
|
73
|
+
} = loginResponse,
|
|
74
|
+
rest = _objectWithoutPropertiesLoose(loginResponse, _excluded);
|
|
75
|
+
if (user.redirectLocation) {
|
|
76
|
+
window.location.href = user.redirectLocation;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (isMfaRequired(user, store.root.appName)) {
|
|
80
|
+
setActivateState({
|
|
81
|
+
step: ActivateAccountStep.success
|
|
82
|
+
});
|
|
83
|
+
const mfaRequiredState = await actions.getMfaRequiredState(user);
|
|
84
|
+
actions.setAuthState(mfaRequiredState);
|
|
85
|
+
await delay(1000);
|
|
86
|
+
onRedirectTo(routes.loginUrl, {
|
|
87
|
+
preserveQueryParams: true
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
var _events$userVerified;
|
|
91
|
+
setActivateState({
|
|
92
|
+
step: ActivateAccountStep.success
|
|
93
|
+
});
|
|
94
|
+
const userVerifiedPayload = {
|
|
95
|
+
email: user.email,
|
|
96
|
+
origin: UserVeirifedOriginTypes.ACTIVATION_LINK,
|
|
97
|
+
id: user.id,
|
|
98
|
+
tenantId: user.tenantId,
|
|
99
|
+
name: user.name,
|
|
100
|
+
createdAt: new Date()
|
|
101
|
+
};
|
|
102
|
+
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
|
|
103
|
+
reportGTMEvent(GTMEventAction.USER_VERIFIED, userVerifiedPayload);
|
|
104
|
+
actions.afterAuthenticationStateUpdate(_extends({
|
|
105
|
+
user
|
|
106
|
+
}, rest), {
|
|
107
|
+
isAuthenticated: true
|
|
108
|
+
});
|
|
109
|
+
await delay(1000);
|
|
110
|
+
await actions.afterAuthNavigation();
|
|
111
|
+
resetActivateState();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
62
114
|
const activateAccount = async _payload => {
|
|
63
115
|
const {
|
|
64
116
|
callback,
|
|
65
117
|
events
|
|
66
118
|
} = _payload,
|
|
67
|
-
payload = _objectWithoutPropertiesLoose(_payload,
|
|
119
|
+
payload = _objectWithoutPropertiesLoose(_payload, _excluded2);
|
|
68
120
|
setActivateState({
|
|
69
121
|
loading: true
|
|
70
122
|
});
|
|
@@ -75,45 +127,48 @@ export default ((store, api, sharedActions) => {
|
|
|
75
127
|
{
|
|
76
128
|
user
|
|
77
129
|
} = _await$api$auth$activ,
|
|
78
|
-
rest = _objectWithoutPropertiesLoose(_await$api$auth$activ,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (isMfaRequired(user, store.root.appName)) {
|
|
84
|
-
setActivateState({
|
|
85
|
-
step: ActivateAccountStep.success
|
|
86
|
-
});
|
|
87
|
-
const mfaRequiredState = await actions.getMfaRequiredState(user);
|
|
88
|
-
actions.setAuthState(mfaRequiredState);
|
|
89
|
-
await delay(1000);
|
|
90
|
-
onRedirectTo(routes.loginUrl, {
|
|
91
|
-
preserveQueryParams: true
|
|
92
|
-
});
|
|
93
|
-
} else {
|
|
94
|
-
var _events$userVerified;
|
|
95
|
-
setActivateState({
|
|
96
|
-
step: ActivateAccountStep.success
|
|
97
|
-
});
|
|
98
|
-
const userVerifiedPayload = {
|
|
99
|
-
email: user.email,
|
|
100
|
-
origin: UserVeirifedOriginTypes.ACTIVATION_LINK,
|
|
101
|
-
id: user.id,
|
|
102
|
-
tenantId: user.tenantId,
|
|
103
|
-
name: user.name,
|
|
104
|
-
createdAt: new Date()
|
|
105
|
-
};
|
|
106
|
-
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
|
|
107
|
-
reportGTMEvent(GTMEventAction.USER_VERIFIED, userVerifiedPayload);
|
|
108
|
-
await actions.afterAuthenticationStateUpdate(_extends({
|
|
130
|
+
rest = _objectWithoutPropertiesLoose(_await$api$auth$activ, _excluded3);
|
|
131
|
+
await handleActivationResponse({
|
|
132
|
+
loginResponse: _extends({
|
|
109
133
|
user
|
|
110
|
-
}, rest),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
134
|
+
}, rest),
|
|
135
|
+
events,
|
|
136
|
+
onRedirectTo,
|
|
137
|
+
routes
|
|
138
|
+
});
|
|
139
|
+
callback == null ? void 0 : callback(true);
|
|
140
|
+
} catch (e) {
|
|
141
|
+
setActivateState({
|
|
142
|
+
loading: false,
|
|
143
|
+
error: errorHandler(e)
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const activateAccountWithCode = async _payload => {
|
|
148
|
+
const {
|
|
149
|
+
callback,
|
|
150
|
+
events
|
|
151
|
+
} = _payload,
|
|
152
|
+
payload = _objectWithoutPropertiesLoose(_payload, _excluded4);
|
|
153
|
+
setActivateState({
|
|
154
|
+
loading: true
|
|
155
|
+
});
|
|
156
|
+
try {
|
|
157
|
+
const onRedirectTo = ContextHolder.for(store.root.appName).onRedirectTo;
|
|
158
|
+
const routes = store.auth.routes;
|
|
159
|
+
const _await$api$auth$activ2 = await api.auth.activateAccountWithOTC(payload),
|
|
160
|
+
{
|
|
161
|
+
user
|
|
162
|
+
} = _await$api$auth$activ2,
|
|
163
|
+
rest = _objectWithoutPropertiesLoose(_await$api$auth$activ2, _excluded5);
|
|
164
|
+
await handleActivationResponse({
|
|
165
|
+
loginResponse: _extends({
|
|
166
|
+
user
|
|
167
|
+
}, rest),
|
|
168
|
+
events,
|
|
169
|
+
onRedirectTo,
|
|
170
|
+
routes
|
|
171
|
+
});
|
|
117
172
|
callback == null ? void 0 : callback(true);
|
|
118
173
|
} catch (e) {
|
|
119
174
|
setActivateState({
|
|
@@ -126,7 +181,7 @@ export default ((store, api, sharedActions) => {
|
|
|
126
181
|
const {
|
|
127
182
|
callback
|
|
128
183
|
} = payload,
|
|
129
|
-
params = _objectWithoutPropertiesLoose(payload,
|
|
184
|
+
params = _objectWithoutPropertiesLoose(payload, _excluded6);
|
|
130
185
|
setActivateStrategyState({
|
|
131
186
|
loading: true
|
|
132
187
|
});
|
|
@@ -149,7 +204,7 @@ export default ((store, api, sharedActions) => {
|
|
|
149
204
|
const {
|
|
150
205
|
callback
|
|
151
206
|
} = payload,
|
|
152
|
-
body = _objectWithoutPropertiesLoose(payload,
|
|
207
|
+
body = _objectWithoutPropertiesLoose(payload, _excluded7);
|
|
153
208
|
actions.setTeamLoader({
|
|
154
209
|
key: TeamStateKeys.RESEND_ACTIVATE_LINK,
|
|
155
210
|
value: body.email
|
|
@@ -185,6 +240,7 @@ export default ((store, api, sharedActions) => {
|
|
|
185
240
|
activateAccount,
|
|
186
241
|
preActivateAccount,
|
|
187
242
|
getActivateAccountStrategy,
|
|
188
|
-
resendActivationEmail
|
|
243
|
+
resendActivationEmail,
|
|
244
|
+
activateAccountWithCode
|
|
189
245
|
};
|
|
190
246
|
});
|
|
@@ -21,6 +21,9 @@ export type IPreActivateAccount = {
|
|
|
21
21
|
export interface IActivateAccountPayload extends IActivateAccount {
|
|
22
22
|
events?: CustomEventsOptions;
|
|
23
23
|
}
|
|
24
|
+
export interface IActivateAccountWithOTCPayload extends IActivateAccountPayload {
|
|
25
|
+
code: string;
|
|
26
|
+
}
|
|
24
27
|
export type ActivateAccountStrategyState = WithStatus & {
|
|
25
28
|
strategy?: IGetActivateAccountStrategyResponse;
|
|
26
29
|
};
|
|
@@ -32,5 +32,7 @@ export const defaultFronteggRoutes = {
|
|
|
32
32
|
hostedLoginRedirectUrl: '/oauth/callback',
|
|
33
33
|
openAppUrl: '/account/redirect',
|
|
34
34
|
unlockAccountUrl: '/account/unlock',
|
|
35
|
+
activateWithOTCUrl: '/account/activate/code',
|
|
36
|
+
acceptInvitationWithOTCUrl: '/account/invitation/code',
|
|
35
37
|
mfaMobileAuthenticator: '/account/mfa-mobile-authenticator'
|
|
36
38
|
};
|
package/auth/interfaces.d.ts
CHANGED
|
@@ -129,6 +129,10 @@ export type AuthPageRoutes = {
|
|
|
129
129
|
* the page whither need to redirect in the case when a user want to activate his account
|
|
130
130
|
*/
|
|
131
131
|
activateUrl: string;
|
|
132
|
+
/**
|
|
133
|
+
* the page whither need to redirect in the case when a user want to activate his account with code
|
|
134
|
+
*/
|
|
135
|
+
activateWithOTCUrl: string;
|
|
132
136
|
/**
|
|
133
137
|
* the page whither need to redirect in the case when a user want to impersonate another user
|
|
134
138
|
*/
|
|
@@ -137,6 +141,10 @@ export type AuthPageRoutes = {
|
|
|
137
141
|
* the page whether you need to redirect in the case when a user want to accept invite to tenant
|
|
138
142
|
*/
|
|
139
143
|
acceptInvitationUrl: string;
|
|
144
|
+
/**
|
|
145
|
+
* the page whether you need to redirect in the case when a user wants to accept invite to tenant with OTC
|
|
146
|
+
*/
|
|
147
|
+
acceptInvitationWithOTCUrl: string;
|
|
140
148
|
/**
|
|
141
149
|
* the page in the case a user forgot his account password
|
|
142
150
|
*/
|
package/index.js
CHANGED
|
@@ -3,5 +3,6 @@ declare const _default: (store: FronteggState, api: RestApi, actions: SharedActi
|
|
|
3
3
|
setAcceptInvitationState: (state: Partial<import("../..").AcceptInvitationState>) => void;
|
|
4
4
|
resetAcceptInvitationState: () => void;
|
|
5
5
|
acceptInvitation: (payload: import("@frontegg/rest-api").IAcceptInvitation) => Promise<void>;
|
|
6
|
+
acceptInvitationWithOTC: (payload: import("@frontegg/rest-api").IAcceptInvitationWithOTC) => Promise<void>;
|
|
6
7
|
};
|
|
7
8
|
export default _default;
|
|
@@ -7,5 +7,6 @@ declare const _default: (store: FronteggState, api: RestApi, actions: SharedActi
|
|
|
7
7
|
preActivateAccount: (payload: import("../..").IPreActivateAccount) => Promise<void>;
|
|
8
8
|
getActivateAccountStrategy: (payload: import("../../interfaces").WithCallback<import("@frontegg/rest-api").IGetActivateAccountStrategy, import("@frontegg/rest-api").IGetActivateAccountStrategyResponse>) => Promise<void>;
|
|
9
9
|
resendActivationEmail: (payload: import("../../interfaces").WithCallback<import("@frontegg/rest-api").IResendActivationEmail>) => Promise<void>;
|
|
10
|
+
activateAccountWithCode: (_payload: import("../../interfaces").WithCallback<import("../..").IActivateAccountWithOTCPayload>) => Promise<void>;
|
|
10
11
|
};
|
|
11
12
|
export default _default;
|
|
@@ -39,10 +39,35 @@ var _default = (store, api, sharedActions) => {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
const acceptInvitationWithOTC = async payload => {
|
|
43
|
+
if (!payload.token || !payload.userId || !payload.code) {
|
|
44
|
+
setAcceptInvitationState({
|
|
45
|
+
error: undefined,
|
|
46
|
+
step: _interfaces.AcceptInvitationStep.invalid
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
setAcceptInvitationState({
|
|
52
|
+
error: undefined,
|
|
53
|
+
step: _interfaces.AcceptInvitationStep.pending
|
|
54
|
+
});
|
|
55
|
+
await api.auth.acceptInvitationWithOTC(payload);
|
|
56
|
+
setAcceptInvitationState({
|
|
57
|
+
step: _interfaces.AcceptInvitationStep.success
|
|
58
|
+
});
|
|
59
|
+
} catch (e) {
|
|
60
|
+
setAcceptInvitationState({
|
|
61
|
+
step: _interfaces.AcceptInvitationStep.failed,
|
|
62
|
+
error: (0, _helpers.errorHandler)(e)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
42
66
|
return {
|
|
43
67
|
setAcceptInvitationState,
|
|
44
68
|
resetAcceptInvitationState,
|
|
45
|
-
acceptInvitation
|
|
69
|
+
acceptInvitation,
|
|
70
|
+
acceptInvitationWithOTC
|
|
46
71
|
};
|
|
47
72
|
};
|
|
48
73
|
exports.default = _default;
|
|
@@ -15,10 +15,13 @@ var _interfaces2 = require("../interfaces");
|
|
|
15
15
|
var _gtm = require("../../helpers/gtm");
|
|
16
16
|
var _helpers2 = require("../helpers");
|
|
17
17
|
var _interfaces3 = require("../TeamState/interfaces");
|
|
18
|
-
const _excluded = ["
|
|
19
|
-
_excluded2 = ["
|
|
20
|
-
_excluded3 = ["
|
|
21
|
-
_excluded4 = ["callback"]
|
|
18
|
+
const _excluded = ["user"],
|
|
19
|
+
_excluded2 = ["callback", "events"],
|
|
20
|
+
_excluded3 = ["user"],
|
|
21
|
+
_excluded4 = ["callback", "events"],
|
|
22
|
+
_excluded5 = ["user"],
|
|
23
|
+
_excluded6 = ["callback"],
|
|
24
|
+
_excluded7 = ["callback"];
|
|
22
25
|
var _default = (store, api, sharedActions) => {
|
|
23
26
|
const actions = sharedActions;
|
|
24
27
|
const setActivateState = state => {
|
|
@@ -66,12 +69,61 @@ var _default = (store, api, sharedActions) => {
|
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
};
|
|
72
|
+
const handleActivationResponse = async ({
|
|
73
|
+
loginResponse,
|
|
74
|
+
events,
|
|
75
|
+
onRedirectTo,
|
|
76
|
+
routes
|
|
77
|
+
}) => {
|
|
78
|
+
const {
|
|
79
|
+
user
|
|
80
|
+
} = loginResponse,
|
|
81
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(loginResponse, _excluded);
|
|
82
|
+
if (user.redirectLocation) {
|
|
83
|
+
window.location.href = user.redirectLocation;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if ((0, _helpers2.isMfaRequired)(user, store.root.appName)) {
|
|
87
|
+
setActivateState({
|
|
88
|
+
step: _interfaces.ActivateAccountStep.success
|
|
89
|
+
});
|
|
90
|
+
const mfaRequiredState = await actions.getMfaRequiredState(user);
|
|
91
|
+
actions.setAuthState(mfaRequiredState);
|
|
92
|
+
await (0, _helpers.delay)(1000);
|
|
93
|
+
onRedirectTo(routes.loginUrl, {
|
|
94
|
+
preserveQueryParams: true
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
var _events$userVerified;
|
|
98
|
+
setActivateState({
|
|
99
|
+
step: _interfaces.ActivateAccountStep.success
|
|
100
|
+
});
|
|
101
|
+
const userVerifiedPayload = {
|
|
102
|
+
email: user.email,
|
|
103
|
+
origin: _interfaces2.UserVeirifedOriginTypes.ACTIVATION_LINK,
|
|
104
|
+
id: user.id,
|
|
105
|
+
tenantId: user.tenantId,
|
|
106
|
+
name: user.name,
|
|
107
|
+
createdAt: new Date()
|
|
108
|
+
};
|
|
109
|
+
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
|
|
110
|
+
(0, _gtm.reportGTMEvent)(_gtm.GTMEventAction.USER_VERIFIED, userVerifiedPayload);
|
|
111
|
+
actions.afterAuthenticationStateUpdate((0, _extends2.default)({
|
|
112
|
+
user
|
|
113
|
+
}, rest), {
|
|
114
|
+
isAuthenticated: true
|
|
115
|
+
});
|
|
116
|
+
await (0, _helpers.delay)(1000);
|
|
117
|
+
await actions.afterAuthNavigation();
|
|
118
|
+
resetActivateState();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
69
121
|
const activateAccount = async _payload => {
|
|
70
122
|
const {
|
|
71
123
|
callback,
|
|
72
124
|
events
|
|
73
125
|
} = _payload,
|
|
74
|
-
payload = (0, _objectWithoutPropertiesLoose2.default)(_payload,
|
|
126
|
+
payload = (0, _objectWithoutPropertiesLoose2.default)(_payload, _excluded2);
|
|
75
127
|
setActivateState({
|
|
76
128
|
loading: true
|
|
77
129
|
});
|
|
@@ -82,45 +134,48 @@ var _default = (store, api, sharedActions) => {
|
|
|
82
134
|
{
|
|
83
135
|
user
|
|
84
136
|
} = _await$api$auth$activ,
|
|
85
|
-
rest = (0, _objectWithoutPropertiesLoose2.default)(_await$api$auth$activ,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if ((0, _helpers2.isMfaRequired)(user, store.root.appName)) {
|
|
91
|
-
setActivateState({
|
|
92
|
-
step: _interfaces.ActivateAccountStep.success
|
|
93
|
-
});
|
|
94
|
-
const mfaRequiredState = await actions.getMfaRequiredState(user);
|
|
95
|
-
actions.setAuthState(mfaRequiredState);
|
|
96
|
-
await (0, _helpers.delay)(1000);
|
|
97
|
-
onRedirectTo(routes.loginUrl, {
|
|
98
|
-
preserveQueryParams: true
|
|
99
|
-
});
|
|
100
|
-
} else {
|
|
101
|
-
var _events$userVerified;
|
|
102
|
-
setActivateState({
|
|
103
|
-
step: _interfaces.ActivateAccountStep.success
|
|
104
|
-
});
|
|
105
|
-
const userVerifiedPayload = {
|
|
106
|
-
email: user.email,
|
|
107
|
-
origin: _interfaces2.UserVeirifedOriginTypes.ACTIVATION_LINK,
|
|
108
|
-
id: user.id,
|
|
109
|
-
tenantId: user.tenantId,
|
|
110
|
-
name: user.name,
|
|
111
|
-
createdAt: new Date()
|
|
112
|
-
};
|
|
113
|
-
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, userVerifiedPayload);
|
|
114
|
-
(0, _gtm.reportGTMEvent)(_gtm.GTMEventAction.USER_VERIFIED, userVerifiedPayload);
|
|
115
|
-
await actions.afterAuthenticationStateUpdate((0, _extends2.default)({
|
|
137
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(_await$api$auth$activ, _excluded3);
|
|
138
|
+
await handleActivationResponse({
|
|
139
|
+
loginResponse: (0, _extends2.default)({
|
|
116
140
|
user
|
|
117
|
-
}, rest),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
141
|
+
}, rest),
|
|
142
|
+
events,
|
|
143
|
+
onRedirectTo,
|
|
144
|
+
routes
|
|
145
|
+
});
|
|
146
|
+
callback == null ? void 0 : callback(true);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
setActivateState({
|
|
149
|
+
loading: false,
|
|
150
|
+
error: (0, _helpers.errorHandler)(e)
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const activateAccountWithCode = async _payload => {
|
|
155
|
+
const {
|
|
156
|
+
callback,
|
|
157
|
+
events
|
|
158
|
+
} = _payload,
|
|
159
|
+
payload = (0, _objectWithoutPropertiesLoose2.default)(_payload, _excluded4);
|
|
160
|
+
setActivateState({
|
|
161
|
+
loading: true
|
|
162
|
+
});
|
|
163
|
+
try {
|
|
164
|
+
const onRedirectTo = _restApi.ContextHolder.for(store.root.appName).onRedirectTo;
|
|
165
|
+
const routes = store.auth.routes;
|
|
166
|
+
const _await$api$auth$activ2 = await api.auth.activateAccountWithOTC(payload),
|
|
167
|
+
{
|
|
168
|
+
user
|
|
169
|
+
} = _await$api$auth$activ2,
|
|
170
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(_await$api$auth$activ2, _excluded5);
|
|
171
|
+
await handleActivationResponse({
|
|
172
|
+
loginResponse: (0, _extends2.default)({
|
|
173
|
+
user
|
|
174
|
+
}, rest),
|
|
175
|
+
events,
|
|
176
|
+
onRedirectTo,
|
|
177
|
+
routes
|
|
178
|
+
});
|
|
124
179
|
callback == null ? void 0 : callback(true);
|
|
125
180
|
} catch (e) {
|
|
126
181
|
setActivateState({
|
|
@@ -133,7 +188,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
133
188
|
const {
|
|
134
189
|
callback
|
|
135
190
|
} = payload,
|
|
136
|
-
params = (0, _objectWithoutPropertiesLoose2.default)(payload,
|
|
191
|
+
params = (0, _objectWithoutPropertiesLoose2.default)(payload, _excluded6);
|
|
137
192
|
setActivateStrategyState({
|
|
138
193
|
loading: true
|
|
139
194
|
});
|
|
@@ -156,7 +211,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
156
211
|
const {
|
|
157
212
|
callback
|
|
158
213
|
} = payload,
|
|
159
|
-
body = (0, _objectWithoutPropertiesLoose2.default)(payload,
|
|
214
|
+
body = (0, _objectWithoutPropertiesLoose2.default)(payload, _excluded7);
|
|
160
215
|
actions.setTeamLoader({
|
|
161
216
|
key: _interfaces3.TeamStateKeys.RESEND_ACTIVATE_LINK,
|
|
162
217
|
value: body.email
|
|
@@ -192,7 +247,8 @@ var _default = (store, api, sharedActions) => {
|
|
|
192
247
|
activateAccount,
|
|
193
248
|
preActivateAccount,
|
|
194
249
|
getActivateAccountStrategy,
|
|
195
|
-
resendActivationEmail
|
|
250
|
+
resendActivationEmail,
|
|
251
|
+
activateAccountWithCode
|
|
196
252
|
};
|
|
197
253
|
};
|
|
198
254
|
exports.default = _default;
|
|
@@ -40,6 +40,8 @@ const defaultFronteggRoutes = {
|
|
|
40
40
|
hostedLoginRedirectUrl: '/oauth/callback',
|
|
41
41
|
openAppUrl: '/account/redirect',
|
|
42
42
|
unlockAccountUrl: '/account/unlock',
|
|
43
|
+
activateWithOTCUrl: '/account/activate/code',
|
|
44
|
+
acceptInvitationWithOTCUrl: '/account/invitation/code',
|
|
43
45
|
mfaMobileAuthenticator: '/account/mfa-mobile-authenticator'
|
|
44
46
|
};
|
|
45
47
|
exports.defaultFronteggRoutes = defaultFronteggRoutes;
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.16.0",
|
|
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": "3.2.
|
|
10
|
+
"@frontegg/rest-api": "3.2.2",
|
|
11
11
|
"fast-deep-equal": "3.1.3",
|
|
12
12
|
"get-value": "^3.0.1",
|
|
13
13
|
"proxy-compare": "^3.0.0",
|