@frontegg/redux-store 4.39.0 → 4.40.1

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.
@@ -65,9 +65,7 @@ export declare function refreshToken(): Generator<import("redux-saga/effects").S
65
65
  callback?: ((data: import("@frontegg/rest-api").ITenantsResponse[] | null, error?: string | undefined) => void) | undefined;
66
66
  } | undefined;
67
67
  type: string;
68
- }>, void, {
69
- routes: any;
70
- } & import("@frontegg/rest-api").IUserProfile & {
68
+ }>, void, AuthState & import("@frontegg/rest-api").IUserProfile & {
71
69
  mfaRequired: boolean;
72
70
  accessToken: string;
73
71
  refreshToken: string;
package/auth/index.js CHANGED
@@ -1056,7 +1056,7 @@ function* getMfaRequiredState(user) {
1056
1056
  function* refreshToken() {
1057
1057
  try {
1058
1058
  const onRedirectTo = ContextHolder.onRedirectTo;
1059
- const { routes } = yield select((state) => state.auth);
1059
+ const { routes, loginState } = yield select((state) => state.auth);
1060
1060
  const user = yield call(api.auth.refreshToken);
1061
1061
  if (isMfaRequired(user)) {
1062
1062
  const mfaRequiredState = yield getMfaRequiredState(user);
@@ -1066,9 +1066,14 @@ function* refreshToken() {
1066
1066
  else {
1067
1067
  yield put(actions.loadTenants());
1068
1068
  yield put(actions.setState({ user, isAuthenticated: true }));
1069
- if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signupUrl, routes.oidcRedirectUrl].includes(window.location.pathname) ||
1069
+ if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signUpUrl, routes.oidcRedirectUrl].includes(window.location.pathname) ||
1070
1070
  (window.location.pathname.endsWith(routes.activateUrl) && user.verified)) {
1071
- yield afterAuthNavigation();
1071
+ if (loginState.isNewUser && routes.signUpSuccessUrl && routes.socialLoginCallbackUrl === window.location.pathname) {
1072
+ onRedirectTo(routes.signUpSuccessUrl, { refresh: routes.signUpSuccessUrl.startsWith('http') });
1073
+ }
1074
+ else {
1075
+ yield afterAuthNavigation();
1076
+ }
1072
1077
  }
1073
1078
  }
1074
1079
  }
@@ -2448,6 +2453,7 @@ function* loginViaSocialLogin({ payload }) {
2448
2453
  const { email, isNewUser } = yield call(api.auth.loginViaSocialLogin, payload);
2449
2454
  yield put(actions.setLoginState({ email, isNewUser }));
2450
2455
  yield refreshToken();
2456
+ yield put(actions.setSocialLoginsState({ loading: false }));
2451
2457
  }
2452
2458
  catch (e) {
2453
2459
  yield put(actions.setSocialLoginsState({ loading: false, error: (_a = e.message) !== null && _a !== void 0 ? _a : 'Failed to authenticate', firstLoad: false }));
@@ -1058,7 +1058,7 @@ function* getMfaRequiredState(user) {
1058
1058
  function* refreshToken() {
1059
1059
  try {
1060
1060
  const onRedirectTo = restApi.ContextHolder.onRedirectTo;
1061
- const { routes } = yield effects.select((state) => state.auth);
1061
+ const { routes, loginState } = yield effects.select((state) => state.auth);
1062
1062
  const user = yield effects.call(restApi.api.auth.refreshToken);
1063
1063
  if (isMfaRequired(user)) {
1064
1064
  const mfaRequiredState = yield getMfaRequiredState(user);
@@ -1068,9 +1068,14 @@ function* refreshToken() {
1068
1068
  else {
1069
1069
  yield effects.put(actions.loadTenants());
1070
1070
  yield effects.put(actions.setState({ user, isAuthenticated: true }));
1071
- if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signupUrl, routes.oidcRedirectUrl].includes(window.location.pathname) ||
1071
+ if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signUpUrl, routes.oidcRedirectUrl].includes(window.location.pathname) ||
1072
1072
  (window.location.pathname.endsWith(routes.activateUrl) && user.verified)) {
1073
- yield afterAuthNavigation();
1073
+ if (loginState.isNewUser && routes.signUpSuccessUrl && routes.socialLoginCallbackUrl === window.location.pathname) {
1074
+ onRedirectTo(routes.signUpSuccessUrl, { refresh: routes.signUpSuccessUrl.startsWith('http') });
1075
+ }
1076
+ else {
1077
+ yield afterAuthNavigation();
1078
+ }
1074
1079
  }
1075
1080
  }
1076
1081
  }
@@ -2450,6 +2455,7 @@ function* loginViaSocialLogin({ payload }) {
2450
2455
  const { email, isNewUser } = yield effects.call(restApi.api.auth.loginViaSocialLogin, payload);
2451
2456
  yield effects.put(actions.setLoginState({ email, isNewUser }));
2452
2457
  yield refreshToken();
2458
+ yield effects.put(actions.setSocialLoginsState({ loading: false }));
2453
2459
  }
2454
2460
  catch (e) {
2455
2461
  yield effects.put(actions.setSocialLoginsState({ loading: false, error: (_a = e.message) !== null && _a !== void 0 ? _a : 'Failed to authenticate', firstLoad: false }));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
3
  "libName": "FronteggReduxStore",
4
- "version": "4.39.0",
4
+ "version": "4.40.1",
5
5
  "author": "Frontegg LTD",
6
6
  "main": "./node/index.js",
7
7
  "module": "./index.js",