@frontegg/redux-store 5.61.0 → 6.0.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/audits/AuditLogsState/index.d.ts +47 -47
- package/audits/AuditLogsState/index.js +28 -0
- package/audits/AuditLogsState/interfaces.d.ts +19 -19
- package/audits/AuditLogsState/interfaces.js +1 -0
- package/audits/AuditLogsState/saga.d.ts +2 -2
- package/audits/AuditLogsState/saga.js +166 -0
- package/audits/AuditsMetadataState/index.d.ts +35 -35
- package/audits/AuditsMetadataState/index.js +18 -0
- package/audits/AuditsMetadataState/interfaces.d.ts +17 -17
- package/audits/AuditsMetadataState/interfaces.js +1 -0
- package/audits/AuditsMetadataState/saga.d.ts +2 -2
- package/audits/AuditsMetadataState/saga.js +56 -0
- package/audits/backward-compatibility/index.d.ts +4 -4
- package/audits/backward-compatibility/index.js +4 -4
- package/audits/backward-compatibility/initialState.d.ts +2 -2
- package/audits/backward-compatibility/initialState.js +20 -0
- package/audits/backward-compatibility/interfaces.d.ts +55 -55
- package/audits/backward-compatibility/interfaces.js +1 -0
- package/audits/backward-compatibility/reducer.d.ts +35 -35
- package/audits/backward-compatibility/reducer.js +129 -0
- package/audits/backward-compatibility/saga.d.ts +1 -1
- package/audits/backward-compatibility/saga.js +187 -0
- package/audits/dummy.d.ts +10 -10
- package/audits/dummy.js +191 -0
- package/audits/index.d.ts +40 -40
- package/audits/index.js +18 -362
- package/audits/initialState.d.ts +2 -2
- package/audits/initialState.js +6 -0
- package/audits/interfaces.d.ts +6 -6
- package/audits/interfaces.js +1 -0
- package/audits/reducer.d.ts +31 -31
- package/audits/reducer.js +23 -0
- package/audits/saga.d.ts +2 -2
- package/audits/saga.js +9 -0
- package/audits/utils.d.ts +14 -14
- package/audits/utils.js +13 -0
- package/auth/AcceptInvitationState/index.d.ts +85 -85
- package/auth/AcceptInvitationState/index.js +20 -0
- package/auth/AcceptInvitationState/interfaces.d.ts +11 -11
- package/auth/AcceptInvitationState/interfaces.js +9 -0
- package/auth/AcceptInvitationState/saga.d.ts +1 -1
- package/auth/AcceptInvitationState/saga.js +41 -0
- package/auth/AccountSettingsState/index.d.ts +92 -92
- package/auth/AccountSettingsState/index.js +22 -0
- package/auth/AccountSettingsState/interfaces.d.ts +10 -10
- package/auth/AccountSettingsState/interfaces.js +1 -0
- package/auth/AccountSettingsState/saga.d.ts +2 -2
- package/auth/AccountSettingsState/saga.js +133 -0
- package/auth/ActivateState/index.d.ts +130 -130
- package/auth/ActivateState/index.js +35 -0
- package/auth/ActivateState/interfaces.d.ts +26 -26
- package/auth/ActivateState/interfaces.js +8 -0
- package/auth/ActivateState/saga.d.ts +1 -1
- package/auth/ActivateState/saga.js +187 -0
- package/auth/ApiTokensState/index.d.ts +119 -119
- package/auth/ApiTokensState/index.js +54 -0
- package/auth/ApiTokensState/interfaces.d.ts +49 -49
- package/auth/ApiTokensState/interfaces.js +7 -0
- package/auth/ApiTokensState/saga.d.ts +2 -2
- package/auth/ApiTokensState/saga.js +410 -0
- package/auth/ForgotPasswordState/index.d.ts +90 -90
- package/auth/ForgotPasswordState/index.js +29 -0
- package/auth/ForgotPasswordState/interfaces.d.ts +18 -18
- package/auth/ForgotPasswordState/interfaces.js +6 -0
- package/auth/ForgotPasswordState/saga.d.ts +8 -8
- package/auth/ForgotPasswordState/saga.js +83 -0
- package/auth/LoginState/index.d.ts +132 -144
- package/auth/LoginState/index.js +64 -0
- package/auth/LoginState/interfaces.d.ts +41 -60
- package/auth/LoginState/interfaces.js +17 -0
- package/auth/LoginState/saga.d.ts +80 -84
- package/auth/LoginState/saga.js +860 -0
- package/auth/MfaState/index.d.ts +92 -92
- package/auth/MfaState/index.js +28 -0
- package/auth/MfaState/interfaces.d.ts +12 -12
- package/auth/MfaState/interfaces.js +6 -0
- package/auth/MfaState/saga.d.ts +2 -2
- package/auth/MfaState/saga.js +252 -0
- package/auth/ProfileState/index.d.ts +90 -90
- package/auth/ProfileState/index.js +24 -0
- package/auth/ProfileState/interfaces.d.ts +9 -9
- package/auth/ProfileState/interfaces.js +1 -0
- package/auth/ProfileState/saga.d.ts +2 -2
- package/auth/ProfileState/saga.js +230 -0
- package/auth/ResetPhoneNumberState/index.d.ts +96 -96
- package/auth/ResetPhoneNumberState/index.js +27 -0
- package/auth/ResetPhoneNumberState/interfaces.d.ts +18 -18
- package/auth/ResetPhoneNumberState/interfaces.js +7 -0
- package/auth/ResetPhoneNumberState/saga.d.ts +17 -17
- package/auth/ResetPhoneNumberState/saga.js +127 -0
- package/auth/RolesState/index.d.ts +100 -100
- package/auth/RolesState/index.js +37 -0
- package/auth/RolesState/interfaces.d.ts +7 -7
- package/auth/RolesState/interfaces.js +1 -0
- package/auth/RolesState/saga.d.ts +1 -1
- package/auth/RolesState/saga.js +197 -0
- package/auth/SSOState/index.d.ts +224 -224
- package/auth/SSOState/index.js +83 -0
- package/auth/SSOState/interfaces.d.ts +92 -92
- package/auth/SSOState/interfaces.js +28 -0
- package/auth/SSOState/saga.d.ts +2 -2
- package/auth/SSOState/saga.js +523 -0
- package/auth/SSOState/saga.v2.d.ts +1 -1
- package/auth/SSOState/saga.v2.js +501 -0
- package/auth/SecurityPolicyState/index.d.ts +456 -502
- package/auth/SecurityPolicyState/index.js +64 -0
- package/auth/SecurityPolicyState/interfaces.d.ts +26 -28
- package/auth/SecurityPolicyState/interfaces.js +1 -0
- package/auth/SecurityPolicyState/saga.d.ts +18 -24
- package/auth/SecurityPolicyState/saga.js +464 -0
- package/auth/SignUp/index.d.ts +86 -86
- package/auth/SignUp/index.js +25 -0
- package/auth/SignUp/interfaces.d.ts +19 -19
- package/auth/SignUp/interfaces.js +6 -0
- package/auth/SignUp/saga.d.ts +49 -49
- package/auth/SignUp/saga.js +147 -0
- package/auth/SocialLogins/index.d.ts +91 -91
- package/auth/SocialLogins/index.js +26 -0
- package/auth/SocialLogins/interfaces.d.ts +13 -13
- package/auth/SocialLogins/interfaces.js +1 -0
- package/auth/SocialLogins/saga.d.ts +10 -10
- package/auth/SocialLogins/saga.js +140 -0
- package/auth/TeamState/index.d.ts +168 -168
- package/auth/TeamState/index.js +111 -0
- package/auth/TeamState/interfaces.d.ts +78 -78
- package/auth/TeamState/interfaces.js +16 -0
- package/auth/TeamState/saga.d.ts +2 -2
- package/auth/TeamState/saga.js +1123 -0
- package/auth/TenantsState/index.d.ts +104 -104
- package/auth/TenantsState/index.js +31 -0
- package/auth/TenantsState/interfaces.d.ts +9 -9
- package/auth/TenantsState/interfaces.js +1 -0
- package/auth/TenantsState/saga.d.ts +2 -2
- package/auth/TenantsState/saga.js +136 -0
- package/auth/dummy.d.ts +28 -28
- package/auth/dummy.js +250 -0
- package/auth/index.d.ts +378 -392
- package/auth/index.js +46 -4078
- package/auth/initialState.d.ts +3 -3
- package/auth/initialState.js +58 -0
- package/auth/interfaces.d.ts +161 -161
- package/auth/interfaces.js +14 -0
- package/auth/reducer.d.ts +356 -370
- package/auth/reducer.js +39 -0
- package/auth/saga.d.ts +2 -2
- package/auth/saga.js +24 -0
- package/auth/utils.d.ts +162 -165
- package/auth/utils.js +74 -0
- package/connectivity/ConnectivityState/index.d.ts +292 -292
- package/connectivity/ConnectivityState/index.js +94 -0
- package/connectivity/consts.d.ts +12 -12
- package/connectivity/consts.js +71 -0
- package/connectivity/index.d.ts +40 -40
- package/connectivity/index.js +12 -454
- package/connectivity/interfaces.d.ts +112 -112
- package/connectivity/interfaces.js +1 -0
- package/connectivity/reducer.d.ts +31 -31
- package/connectivity/reducer.js +25 -0
- package/connectivity/saga.d.ts +1 -1
- package/connectivity/saga.js +546 -0
- package/constants.d.ts +7 -7
- package/constants.js +7 -0
- package/helpers.d.ts +5 -5
- package/helpers.js +37 -0
- package/index.d.ts +28 -28
- package/index.js +17 -15
- package/interfaces.d.ts +15 -15
- package/interfaces.js +1 -0
- package/node/audits/AuditLogsState/index.js +43 -0
- package/node/audits/AuditLogsState/interfaces.js +5 -0
- package/node/audits/AuditLogsState/saga.js +181 -0
- package/node/audits/AuditsMetadataState/index.js +33 -0
- package/node/audits/AuditsMetadataState/interfaces.js +5 -0
- package/node/audits/AuditsMetadataState/saga.js +67 -0
- package/node/audits/backward-compatibility/index.js +52 -12
- package/node/audits/backward-compatibility/initialState.js +27 -0
- package/node/audits/backward-compatibility/interfaces.js +5 -0
- package/node/audits/backward-compatibility/reducer.js +144 -0
- package/node/audits/backward-compatibility/saga.js +199 -0
- package/node/audits/dummy.js +204 -0
- package/node/audits/index.js +124 -364
- package/node/audits/initialState.js +16 -0
- package/node/audits/interfaces.js +5 -0
- package/node/audits/reducer.js +37 -0
- package/node/audits/saga.js +21 -0
- package/node/audits/utils.js +25 -0
- package/node/auth/AcceptInvitationState/index.js +33 -0
- package/node/auth/AcceptInvitationState/interfaces.js +16 -0
- package/node/auth/AcceptInvitationState/saga.js +51 -0
- package/node/auth/AccountSettingsState/index.js +34 -0
- package/node/auth/AccountSettingsState/interfaces.js +5 -0
- package/node/auth/AccountSettingsState/saga.js +145 -0
- package/node/auth/ActivateState/index.js +48 -0
- package/node/auth/ActivateState/interfaces.js +15 -0
- package/node/auth/ActivateState/saga.js +201 -0
- package/node/auth/ApiTokensState/index.js +66 -0
- package/node/auth/ApiTokensState/interfaces.js +14 -0
- package/node/auth/ApiTokensState/saga.js +424 -0
- package/node/auth/ForgotPasswordState/index.js +42 -0
- package/node/auth/ForgotPasswordState/interfaces.js +13 -0
- package/node/auth/ForgotPasswordState/saga.js +98 -0
- package/node/auth/LoginState/index.js +77 -0
- package/node/auth/LoginState/interfaces.js +31 -0
- package/node/auth/LoginState/saga.js +918 -0
- package/node/auth/MfaState/index.js +41 -0
- package/node/auth/MfaState/interfaces.js +13 -0
- package/node/auth/MfaState/saga.js +265 -0
- package/node/auth/ProfileState/index.js +36 -0
- package/node/auth/ProfileState/interfaces.js +5 -0
- package/node/auth/ProfileState/saga.js +245 -0
- package/node/auth/ResetPhoneNumberState/index.js +40 -0
- package/node/auth/ResetPhoneNumberState/interfaces.js +14 -0
- package/node/auth/ResetPhoneNumberState/saga.js +141 -0
- package/node/auth/RolesState/index.js +49 -0
- package/node/auth/RolesState/interfaces.js +5 -0
- package/node/auth/RolesState/saga.js +205 -0
- package/node/auth/SSOState/index.js +95 -0
- package/node/auth/SSOState/interfaces.js +36 -0
- package/node/auth/SSOState/saga.js +535 -0
- package/node/auth/SSOState/saga.v2.js +512 -0
- package/node/auth/SecurityPolicyState/index.js +76 -0
- package/node/auth/SecurityPolicyState/interfaces.js +5 -0
- package/node/auth/SecurityPolicyState/saga.js +472 -0
- package/node/auth/SignUp/index.js +38 -0
- package/node/auth/SignUp/interfaces.js +13 -0
- package/node/auth/SignUp/saga.js +173 -0
- package/node/auth/SocialLogins/index.js +38 -0
- package/node/auth/SocialLogins/interfaces.js +5 -0
- package/node/auth/SocialLogins/saga.js +162 -0
- package/node/auth/TeamState/index.js +123 -0
- package/node/auth/TeamState/interfaces.js +23 -0
- package/node/auth/TeamState/saga.js +1118 -0
- package/node/auth/TenantsState/index.js +43 -0
- package/node/auth/TenantsState/interfaces.js +5 -0
- package/node/auth/TenantsState/saga.js +149 -0
- package/node/auth/dummy.js +284 -0
- package/node/auth/index.js +528 -170
- package/node/auth/initialState.js +86 -0
- package/node/auth/interfaces.js +22 -0
- package/node/auth/reducer.js +68 -0
- package/node/auth/saga.js +51 -0
- package/node/auth/utils.js +104 -0
- package/node/connectivity/ConnectivityState/index.js +107 -0
- package/node/connectivity/consts.js +84 -0
- package/node/connectivity/index.js +64 -455
- package/node/connectivity/interfaces.js +5 -0
- package/node/connectivity/reducer.js +38 -0
- package/node/connectivity/saga.js +560 -0
- package/node/{constants-52e37c08.js → constants.js} +14 -11
- package/node/helpers.js +57 -0
- package/node/index.js +120 -293
- package/node/interfaces.js +5 -0
- package/node/subscriptions/Billing/Information/index.js +42 -0
- package/node/subscriptions/Billing/Information/interfaces.js +5 -0
- package/node/subscriptions/Billing/Information/saga.js +141 -0
- package/node/subscriptions/Billing/Invoices/index.js +55 -0
- package/node/subscriptions/Billing/Invoices/interfaces.js +5 -0
- package/node/subscriptions/Billing/Invoices/saga.js +92 -0
- package/node/subscriptions/Billing/PaymentMethod/index.js +51 -0
- package/node/subscriptions/Billing/PaymentMethod/interfaces.js +13 -0
- package/node/subscriptions/Billing/PaymentMethod/saga.js +98 -0
- package/node/subscriptions/Billing/Subscription/index.js +53 -0
- package/node/subscriptions/Billing/Subscription/interfaces.js +5 -0
- package/node/subscriptions/Billing/Subscription/saga.js +131 -0
- package/node/subscriptions/Billing/index.js +38 -0
- package/node/subscriptions/Billing/interfaces.js +57 -0
- package/node/subscriptions/Billing/saga.js +25 -0
- package/node/subscriptions/Checkout/index.js +47 -0
- package/node/subscriptions/Checkout/interfaces.js +5 -0
- package/node/subscriptions/Checkout/saga.js +129 -0
- package/node/subscriptions/Config/index.js +39 -0
- package/node/subscriptions/Config/interfaces.js +5 -0
- package/node/subscriptions/Config/saga.js +71 -0
- package/node/subscriptions/Plans/index.js +38 -0
- package/node/subscriptions/Plans/interfaces.js +5 -0
- package/node/subscriptions/Plans/saga.js +73 -0
- package/node/subscriptions/Stripe/index.js +39 -0
- package/node/subscriptions/Stripe/interfaces.js +5 -0
- package/node/subscriptions/Stripe/saga.js +44 -0
- package/node/subscriptions/dummy.js +84 -0
- package/node/subscriptions/general.interfaces.js +30 -0
- package/node/subscriptions/index.js +70 -906
- package/node/subscriptions/interfaces.js +83 -0
- package/node/subscriptions/mapper.js +51 -0
- package/node/subscriptions/reducer.js +52 -0
- package/node/subscriptions/saga.js +27 -0
- package/node/subscriptions/utils.js +68 -0
- package/node/toolkit/index.js +163 -99
- package/node/toolkit/redux-saga.js +59 -0
- package/node/toolkit/redux.js +43 -0
- package/node/vendor/VendorState/index.js +26 -0
- package/node/vendor/index.js +66 -13
- package/node/vendor/interfaces.js +5 -0
- package/node/vendor/reducer.js +32 -0
- package/node/vendor/saga.js +48 -0
- package/package.json +12 -11
- package/subscriptions/Billing/Information/index.d.ts +12 -12
- package/subscriptions/Billing/Information/index.js +30 -0
- package/subscriptions/Billing/Information/interfaces.d.ts +14 -14
- package/subscriptions/Billing/Information/interfaces.js +1 -0
- package/subscriptions/Billing/Information/saga.d.ts +52 -52
- package/subscriptions/Billing/Information/saga.js +118 -0
- package/subscriptions/Billing/Invoices/index.d.ts +18 -18
- package/subscriptions/Billing/Invoices/index.js +44 -0
- package/subscriptions/Billing/Invoices/interfaces.d.ts +19 -19
- package/subscriptions/Billing/Invoices/interfaces.js +1 -0
- package/subscriptions/Billing/Invoices/saga.d.ts +13 -13
- package/subscriptions/Billing/Invoices/saga.js +75 -0
- package/subscriptions/Billing/PaymentMethod/index.d.ts +20 -20
- package/subscriptions/Billing/PaymentMethod/index.js +40 -0
- package/subscriptions/Billing/PaymentMethod/interfaces.d.ts +46 -46
- package/subscriptions/Billing/PaymentMethod/interfaces.js +6 -0
- package/subscriptions/Billing/PaymentMethod/saga.d.ts +13 -13
- package/subscriptions/Billing/PaymentMethod/saga.js +81 -0
- package/subscriptions/Billing/Subscription/index.d.ts +16 -16
- package/subscriptions/Billing/Subscription/index.js +42 -0
- package/subscriptions/Billing/Subscription/interfaces.d.ts +18 -18
- package/subscriptions/Billing/Subscription/interfaces.js +1 -0
- package/subscriptions/Billing/Subscription/saga.d.ts +13 -13
- package/subscriptions/Billing/Subscription/saga.js +117 -0
- package/subscriptions/Billing/index.d.ts +54 -54
- package/subscriptions/Billing/index.js +23 -0
- package/subscriptions/Billing/interfaces.d.ts +20 -20
- package/subscriptions/Billing/interfaces.js +5 -0
- package/subscriptions/Billing/saga.d.ts +2 -2
- package/subscriptions/Billing/saga.js +11 -0
- package/subscriptions/Checkout/index.d.ts +14 -14
- package/subscriptions/Checkout/index.js +36 -0
- package/subscriptions/Checkout/interfaces.d.ts +17 -17
- package/subscriptions/Checkout/interfaces.js +1 -0
- package/subscriptions/Checkout/saga.d.ts +5 -5
- package/subscriptions/Checkout/saga.js +110 -0
- package/subscriptions/Config/index.d.ts +10 -10
- package/subscriptions/Config/index.js +28 -0
- package/subscriptions/Config/interfaces.d.ts +16 -16
- package/subscriptions/Config/interfaces.js +1 -0
- package/subscriptions/Config/saga.d.ts +2 -2
- package/subscriptions/Config/saga.js +59 -0
- package/subscriptions/Plans/index.d.ts +10 -10
- package/subscriptions/Plans/index.js +25 -0
- package/subscriptions/Plans/interfaces.d.ts +10 -10
- package/subscriptions/Plans/interfaces.js +1 -0
- package/subscriptions/Plans/saga.d.ts +2 -2
- package/subscriptions/Plans/saga.js +58 -0
- package/subscriptions/Stripe/index.d.ts +11 -11
- package/subscriptions/Stripe/index.js +28 -0
- package/subscriptions/Stripe/interfaces.d.ts +10 -10
- package/subscriptions/Stripe/interfaces.js +1 -0
- package/subscriptions/Stripe/saga.d.ts +1 -1
- package/subscriptions/Stripe/saga.js +34 -0
- package/subscriptions/dummy.d.ts +5 -5
- package/subscriptions/dummy.js +72 -0
- package/subscriptions/general.interfaces.d.ts +49 -49
- package/subscriptions/general.interfaces.js +21 -0
- package/subscriptions/index.d.ts +100 -100
- package/subscriptions/index.js +13 -906
- package/subscriptions/interfaces.d.ts +25 -25
- package/subscriptions/interfaces.js +7 -0
- package/subscriptions/mapper.d.ts +6 -6
- package/subscriptions/mapper.js +36 -0
- package/subscriptions/reducer.d.ts +92 -92
- package/subscriptions/reducer.js +29 -0
- package/subscriptions/saga.d.ts +2 -2
- package/subscriptions/saga.js +12 -0
- package/subscriptions/utils.d.ts +68 -68
- package/subscriptions/utils.js +52 -0
- package/toolkit/index.d.ts +24 -23
- package/toolkit/index.js +106 -94
- package/toolkit/redux-saga.d.ts +4 -4
- package/toolkit/redux-saga.js +3 -0
- package/toolkit/redux.d.ts +3 -2
- package/toolkit/redux.js +1 -0
- package/vendor/VendorState/index.d.ts +20 -20
- package/vendor/VendorState/index.js +13 -0
- package/vendor/index.d.ts +17 -17
- package/vendor/index.js +12 -18
- package/vendor/interfaces.d.ts +3 -3
- package/vendor/interfaces.js +1 -0
- package/vendor/reducer.d.ts +8 -8
- package/vendor/reducer.js +19 -0
- package/vendor/saga.d.ts +8 -8
- package/vendor/saga.js +34 -0
- package/audits/backward-compatibility/package.json +0 -6
- package/constants-4d9682b2.js +0 -9
- package/node/index-5642a636.js +0 -4131
- package/node/index-6906e508.js +0 -151
- package/node/saga-b0d1a607.js +0 -230
- package/saga-7a267fe0.js +0 -223
- package/saga-b6529ffb.js +0 -36
|
@@ -0,0 +1,860 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["callback"],
|
|
4
|
+
_excluded2 = ["callback", "events"],
|
|
5
|
+
_excluded3 = ["callback"];
|
|
6
|
+
import { all, call, delay, put, select, takeLeading } from 'redux-saga/effects';
|
|
7
|
+
import { api, AuthStrategyEnum, ContextHolder, fetch } from '@frontegg/rest-api';
|
|
8
|
+
import { actions } from '../reducer';
|
|
9
|
+
import { FRONTEGG_AFTER_AUTH_REDIRECT_URL, HOSTED_LOGIN_VERIFIER_KEY } from '../../constants';
|
|
10
|
+
import { UserVeirifedOriginTypes } from '../interfaces';
|
|
11
|
+
import { LoginStep } from './interfaces';
|
|
12
|
+
import { loadAllowSignUps } from '../SignUp/saga';
|
|
13
|
+
import { MFAStep } from '../MfaState/interfaces';
|
|
14
|
+
import { userDemo } from '../dummy';
|
|
15
|
+
import { SamlVendors } from '../SSOState/interfaces';
|
|
16
|
+
import { loadVendorPublicInfo } from '../../vendor/saga';
|
|
17
|
+
import { createRandomString, generateCodeChallenge } from '../../helpers';
|
|
18
|
+
import { ResetPhoneNumberStep } from '../ResetPhoneNumberState/interfaces';
|
|
19
|
+
const authStrategyLoginStepMap = {
|
|
20
|
+
[AuthStrategyEnum.Code]: LoginStep.loginWithOtc,
|
|
21
|
+
[AuthStrategyEnum.EmailAndPassword]: LoginStep.loginWithPassword,
|
|
22
|
+
[AuthStrategyEnum.MagicLink]: LoginStep.magicLinkPreLoginSuccess,
|
|
23
|
+
[AuthStrategyEnum.SmsCode]: LoginStep.loginWithSmsOtc
|
|
24
|
+
};
|
|
25
|
+
export function* afterAuthNavigation() {
|
|
26
|
+
var _window;
|
|
27
|
+
|
|
28
|
+
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
29
|
+
const {
|
|
30
|
+
routes,
|
|
31
|
+
includeQueryParam
|
|
32
|
+
} = yield select(state => state.auth);
|
|
33
|
+
const {
|
|
34
|
+
loginUrl,
|
|
35
|
+
logoutUrl,
|
|
36
|
+
socialLoginCallbackUrl,
|
|
37
|
+
activateUrl
|
|
38
|
+
} = routes;
|
|
39
|
+
let {
|
|
40
|
+
authenticatedUrl
|
|
41
|
+
} = routes;
|
|
42
|
+
const afterAuthRedirect = window.localStorage.getItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL);
|
|
43
|
+
|
|
44
|
+
if (afterAuthRedirect && ![loginUrl, logoutUrl, socialLoginCallbackUrl, activateUrl].includes(afterAuthRedirect)) {
|
|
45
|
+
authenticatedUrl = afterAuthRedirect;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
window.localStorage.removeItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL);
|
|
49
|
+
yield delay(200);
|
|
50
|
+
put(actions.resetLoginState());
|
|
51
|
+
const url = new URL((_window = window) == null ? void 0 : _window.location.href);
|
|
52
|
+
let redirectUrl = authenticatedUrl;
|
|
53
|
+
|
|
54
|
+
if (url.searchParams.get('redirectUrl')) {
|
|
55
|
+
var _url$searchParams$get;
|
|
56
|
+
|
|
57
|
+
redirectUrl = (_url$searchParams$get = url.searchParams.get('redirectUrl')) != null ? _url$searchParams$get : authenticatedUrl;
|
|
58
|
+
} else if (includeQueryParam) {
|
|
59
|
+
redirectUrl += window.location.search;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
onRedirectTo(redirectUrl, {
|
|
63
|
+
refresh: redirectUrl.startsWith('http')
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function* refreshMetadata() {
|
|
67
|
+
let ssoACS;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
var _metadata$configurati;
|
|
71
|
+
|
|
72
|
+
const metadata = yield call(api.metadata.getSamlMetadata);
|
|
73
|
+
ssoACS = metadata == null ? void 0 : (_metadata$configurati = metadata.configuration) == null ? void 0 : _metadata$configurati.acsUrl;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
console.error(e);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
yield put(actions.setState({
|
|
79
|
+
ssoACS
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
export function* loadSSOPublicConfigurationFunction() {
|
|
83
|
+
try {
|
|
84
|
+
const {
|
|
85
|
+
isActive
|
|
86
|
+
} = yield call(api.auth.getSSOPublicConfiguration);
|
|
87
|
+
yield put(actions.setState({
|
|
88
|
+
isSSOAuth: isActive
|
|
89
|
+
}));
|
|
90
|
+
} catch (e) {
|
|
91
|
+
console.error(e);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export const isMfaRequired = user => {
|
|
95
|
+
if (user.mfaRequired && user.mfaToken) {
|
|
96
|
+
ContextHolder.setAccessToken(null);
|
|
97
|
+
ContextHolder.setUser(null);
|
|
98
|
+
return true;
|
|
99
|
+
} else {
|
|
100
|
+
ContextHolder.setAccessToken(user.accessToken);
|
|
101
|
+
ContextHolder.setUser(user);
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
export function* getMfaRequiredState(user) {
|
|
106
|
+
let setMfaState = {};
|
|
107
|
+
let step = LoginStep.loginWithTwoFactor;
|
|
108
|
+
const {
|
|
109
|
+
loginState
|
|
110
|
+
} = yield select(state => state.auth);
|
|
111
|
+
const {
|
|
112
|
+
isAllowedToRemember,
|
|
113
|
+
mfaDeviceExpiration
|
|
114
|
+
} = yield call(api.auth.checkIfAllowToRememberMfaDevice, user.mfaToken);
|
|
115
|
+
|
|
116
|
+
if (user.hasOwnProperty('mfaEnrolled') && !user.mfaEnrolled) {
|
|
117
|
+
setMfaState = {
|
|
118
|
+
mfaState: {
|
|
119
|
+
step: MFAStep.verify,
|
|
120
|
+
qrCode: user.qrCode,
|
|
121
|
+
recoveryCode: user.recoveryCode,
|
|
122
|
+
loading: false,
|
|
123
|
+
mfaToken: user.mfaToken
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
step = LoginStep.forceTwoFactor;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return _extends({
|
|
130
|
+
user: undefined,
|
|
131
|
+
isAuthenticated: false
|
|
132
|
+
}, setMfaState, {
|
|
133
|
+
loginState: _extends({}, loginState, {
|
|
134
|
+
mfaToken: user.mfaToken,
|
|
135
|
+
mfaRequired: user.mfaRequired,
|
|
136
|
+
loading: false,
|
|
137
|
+
error: undefined,
|
|
138
|
+
step,
|
|
139
|
+
tenantsLoading: true,
|
|
140
|
+
tenants: [],
|
|
141
|
+
allowRememberMfaDevice: isAllowedToRemember,
|
|
142
|
+
mfaDeviceExpiration
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
export function* refreshToken() {
|
|
147
|
+
try {
|
|
148
|
+
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
149
|
+
const {
|
|
150
|
+
routes,
|
|
151
|
+
loginState
|
|
152
|
+
} = yield select(state => state.auth);
|
|
153
|
+
const {
|
|
154
|
+
user,
|
|
155
|
+
tenants
|
|
156
|
+
} = yield call(api.auth.refreshTokenV2);
|
|
157
|
+
|
|
158
|
+
if (isMfaRequired(user)) {
|
|
159
|
+
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
160
|
+
yield put(actions.setState(mfaRequiredState));
|
|
161
|
+
onRedirectTo(routes.loginUrl, {
|
|
162
|
+
preserveQueryParams: true
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
yield put(actions.setTenantsState({
|
|
166
|
+
tenants,
|
|
167
|
+
loading: false
|
|
168
|
+
}));
|
|
169
|
+
yield put(actions.setState({
|
|
170
|
+
user,
|
|
171
|
+
isAuthenticated: true
|
|
172
|
+
}));
|
|
173
|
+
|
|
174
|
+
if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signUpUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl].some(url => url && window.location.pathname.endsWith(url))) {
|
|
175
|
+
if (loginState.isNewUser && routes.signUpSuccessUrl && routes.socialLoginCallbackUrl === window.location.pathname) {
|
|
176
|
+
onRedirectTo(routes.signUpSuccessUrl, {
|
|
177
|
+
refresh: routes.signUpSuccessUrl.startsWith('http')
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
yield afterAuthNavigation();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} catch (e) {
|
|
185
|
+
ContextHolder.setAccessToken(null);
|
|
186
|
+
ContextHolder.setUser(null);
|
|
187
|
+
yield put(actions.setState({
|
|
188
|
+
user: undefined,
|
|
189
|
+
isAuthenticated: false
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function* requestAuthorize({
|
|
195
|
+
payload: firstTime
|
|
196
|
+
}) {
|
|
197
|
+
const calls = [];
|
|
198
|
+
|
|
199
|
+
if (firstTime) {
|
|
200
|
+
yield put(actions.setState({
|
|
201
|
+
isLoading: true
|
|
202
|
+
}));
|
|
203
|
+
yield put(actions.loadSocialLoginsConfigurationV2());
|
|
204
|
+
calls.push(call(loadAllowSignUps));
|
|
205
|
+
calls.push(call(loadSSOPublicConfigurationFunction));
|
|
206
|
+
calls.push(call(loadVendorPublicInfo));
|
|
207
|
+
calls.push(call(refreshMetadata));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
calls.push(call(refreshToken));
|
|
211
|
+
yield all(calls);
|
|
212
|
+
yield put(actions.setState({
|
|
213
|
+
isLoading: false
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function* refreshTokenSSR(accessToken) {
|
|
218
|
+
if (!accessToken) {
|
|
219
|
+
ContextHolder.setAccessToken(null);
|
|
220
|
+
ContextHolder.setUser(null);
|
|
221
|
+
yield put(actions.setState({
|
|
222
|
+
user: undefined,
|
|
223
|
+
isAuthenticated: false
|
|
224
|
+
}));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
230
|
+
const {
|
|
231
|
+
routes
|
|
232
|
+
} = yield select(state => state.auth);
|
|
233
|
+
const {
|
|
234
|
+
user,
|
|
235
|
+
tenants
|
|
236
|
+
} = yield call(api.auth.generateLoginResponseV2, {
|
|
237
|
+
accessToken
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
if (isMfaRequired(user)) {
|
|
241
|
+
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
242
|
+
yield put(actions.setState(mfaRequiredState));
|
|
243
|
+
onRedirectTo(routes.loginUrl, {
|
|
244
|
+
preserveQueryParams: true
|
|
245
|
+
});
|
|
246
|
+
} else {
|
|
247
|
+
yield put(actions.setTenantsState({
|
|
248
|
+
tenants,
|
|
249
|
+
loading: false
|
|
250
|
+
}));
|
|
251
|
+
yield put(actions.setState({
|
|
252
|
+
user,
|
|
253
|
+
isAuthenticated: true
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
} catch (e) {
|
|
257
|
+
ContextHolder.setAccessToken(null);
|
|
258
|
+
ContextHolder.setUser(null);
|
|
259
|
+
yield put(actions.setState({
|
|
260
|
+
user: undefined,
|
|
261
|
+
isAuthenticated: false
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function* requestAuthorizeSSR({
|
|
267
|
+
payload: accessToken
|
|
268
|
+
}) {
|
|
269
|
+
const calls = [];
|
|
270
|
+
yield put(actions.setState({
|
|
271
|
+
isLoading: true
|
|
272
|
+
}));
|
|
273
|
+
yield put(actions.loadSocialLoginsConfigurationV2());
|
|
274
|
+
calls.push(call(loadAllowSignUps));
|
|
275
|
+
calls.push(call(loadSSOPublicConfigurationFunction));
|
|
276
|
+
calls.push(call(loadVendorPublicInfo));
|
|
277
|
+
calls.push(call(refreshMetadata));
|
|
278
|
+
calls.push(call(refreshTokenSSR, accessToken));
|
|
279
|
+
yield all(calls);
|
|
280
|
+
yield put(actions.setState({
|
|
281
|
+
isLoading: false
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function* requestHostedLoginAuthorize() {
|
|
286
|
+
const {
|
|
287
|
+
routes,
|
|
288
|
+
context,
|
|
289
|
+
onRedirectTo
|
|
290
|
+
} = yield select(state => ({
|
|
291
|
+
routes: state.auth.routes,
|
|
292
|
+
onRedirectTo: state.auth.onRedirectTo,
|
|
293
|
+
context: state.root.context
|
|
294
|
+
}));
|
|
295
|
+
const nonce = createRandomString();
|
|
296
|
+
const code_verifier = createRandomString();
|
|
297
|
+
const code_challenge = yield call(generateCodeChallenge, code_verifier);
|
|
298
|
+
localStorage.setItem(HOSTED_LOGIN_VERIFIER_KEY, code_verifier);
|
|
299
|
+
const redirectUrl = `${window.location.origin}${routes.hostedLoginRedirectUrl}`;
|
|
300
|
+
const baseUrl = fetch.getBaseUrl(context, '/oauth/authorize');
|
|
301
|
+
const oauthUrl = `${baseUrl}/oauth/authorize`;
|
|
302
|
+
const params = {
|
|
303
|
+
response_type: 'code',
|
|
304
|
+
client_id: context.clientId || 'INVALID-CLIENT-ID',
|
|
305
|
+
scope: 'openid email profile',
|
|
306
|
+
redirect_uri: redirectUrl,
|
|
307
|
+
code_challenge: code_challenge,
|
|
308
|
+
code_challenge_method: 'S256',
|
|
309
|
+
nonce
|
|
310
|
+
};
|
|
311
|
+
const searchParams = new URLSearchParams(params);
|
|
312
|
+
const url = `${oauthUrl}?${searchParams.toString()}`;
|
|
313
|
+
onRedirectTo(url, {
|
|
314
|
+
refresh: true
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function* handleHostedLoginCallback({
|
|
319
|
+
payload
|
|
320
|
+
}) {
|
|
321
|
+
const code_verifier = localStorage.getItem(HOSTED_LOGIN_VERIFIER_KEY) || 'INVALID-CODE-VERIFIER';
|
|
322
|
+
const routes = yield select(state => state.auth.routes);
|
|
323
|
+
const redirectUrl = `${window.location.origin}${routes.hostedLoginRedirectUrl}`;
|
|
324
|
+
const body = {
|
|
325
|
+
code: payload.code,
|
|
326
|
+
redirect_uri: redirectUrl,
|
|
327
|
+
code_verifier,
|
|
328
|
+
grant_type: 'authorization_code'
|
|
329
|
+
};
|
|
330
|
+
const user = yield call(api.auth.exchangeOAuthTokens, body);
|
|
331
|
+
yield put(actions.setState({
|
|
332
|
+
user,
|
|
333
|
+
isAuthenticated: true
|
|
334
|
+
}));
|
|
335
|
+
yield put(actions.loadTenants());
|
|
336
|
+
yield afterAuthNavigation();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function* passwordlessPreLogin(_ref) {
|
|
340
|
+
let {
|
|
341
|
+
payload: {
|
|
342
|
+
callback
|
|
343
|
+
}
|
|
344
|
+
} = _ref,
|
|
345
|
+
payload = _objectWithoutPropertiesLoose(_ref.payload, _excluded);
|
|
346
|
+
|
|
347
|
+
try {
|
|
348
|
+
const {
|
|
349
|
+
onRedirectTo,
|
|
350
|
+
routes
|
|
351
|
+
} = yield select(({
|
|
352
|
+
auth: {
|
|
353
|
+
onRedirectTo,
|
|
354
|
+
routes
|
|
355
|
+
}
|
|
356
|
+
}) => ({
|
|
357
|
+
onRedirectTo,
|
|
358
|
+
routes
|
|
359
|
+
}));
|
|
360
|
+
yield put(actions.setLoginState({
|
|
361
|
+
loading: true
|
|
362
|
+
}));
|
|
363
|
+
const preloginRes = yield call(api.auth.passwordlessPreLogin, payload);
|
|
364
|
+
const step = authStrategyLoginStepMap[payload.type];
|
|
365
|
+
|
|
366
|
+
if (step === LoginStep.loginWithSmsOtc && preloginRes.resetPhoneNumberToken) {
|
|
367
|
+
yield put(actions.setResetPhoneNumberState({
|
|
368
|
+
resetPhoneNumberToken: preloginRes.resetPhoneNumberToken,
|
|
369
|
+
step: ResetPhoneNumberStep.VerifyResetPhoneNumber
|
|
370
|
+
}));
|
|
371
|
+
onRedirectTo(routes.resetPhoneNumberUrl);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
yield put(actions.setLoginState({
|
|
376
|
+
step,
|
|
377
|
+
loading: false,
|
|
378
|
+
email: payload.email,
|
|
379
|
+
phoneNumber: preloginRes == null ? void 0 : preloginRes.phoneNumber
|
|
380
|
+
}));
|
|
381
|
+
callback == null ? void 0 : callback();
|
|
382
|
+
} catch (e) {
|
|
383
|
+
yield put(actions.setLoginState({
|
|
384
|
+
error: e.message,
|
|
385
|
+
loading: false
|
|
386
|
+
}));
|
|
387
|
+
callback == null ? void 0 : callback();
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function* passwordlessPostLogin(_ref2) {
|
|
392
|
+
let {
|
|
393
|
+
payload: {
|
|
394
|
+
callback,
|
|
395
|
+
events
|
|
396
|
+
}
|
|
397
|
+
} = _ref2,
|
|
398
|
+
payload = _objectWithoutPropertiesLoose(_ref2.payload, _excluded2);
|
|
399
|
+
|
|
400
|
+
try {
|
|
401
|
+
yield put(actions.setLoginState({
|
|
402
|
+
loading: true
|
|
403
|
+
}));
|
|
404
|
+
const data = yield call(api.auth.passwordlessPostLogin, payload);
|
|
405
|
+
|
|
406
|
+
if (isMfaRequired(data)) {
|
|
407
|
+
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
408
|
+
const {
|
|
409
|
+
routes
|
|
410
|
+
} = yield select(state => state.auth);
|
|
411
|
+
const mfaRequiredState = yield getMfaRequiredState(data);
|
|
412
|
+
yield put(actions.setState(mfaRequiredState));
|
|
413
|
+
onRedirectTo(routes.loginUrl, {
|
|
414
|
+
preserveQueryParams: true
|
|
415
|
+
});
|
|
416
|
+
} else {
|
|
417
|
+
const user = yield call(api.auth.generateLoginResponse, data);
|
|
418
|
+
|
|
419
|
+
if (data.emailVerified) {
|
|
420
|
+
var _events$userVerified;
|
|
421
|
+
|
|
422
|
+
events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, {
|
|
423
|
+
email: user.email,
|
|
424
|
+
origin: UserVeirifedOriginTypes.PASSWORDLESS,
|
|
425
|
+
id: user.id,
|
|
426
|
+
tenantId: user.tenantId,
|
|
427
|
+
createdAt: new Date(),
|
|
428
|
+
name: user.name
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
yield put(actions.loadTenants());
|
|
433
|
+
yield put(actions.setState({
|
|
434
|
+
user,
|
|
435
|
+
isAuthenticated: true
|
|
436
|
+
}));
|
|
437
|
+
yield afterAuthNavigation();
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
callback == null ? void 0 : callback(true);
|
|
441
|
+
} catch (e) {
|
|
442
|
+
var _e$message;
|
|
443
|
+
|
|
444
|
+
yield put(actions.setLoginState({
|
|
445
|
+
error: (_e$message = e.message) != null ? _e$message : 'Failed to authenticate'
|
|
446
|
+
}));
|
|
447
|
+
} finally {
|
|
448
|
+
yield put(actions.setLoginState({
|
|
449
|
+
loading: false
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function* verifyInviteToken({
|
|
455
|
+
payload
|
|
456
|
+
}) {
|
|
457
|
+
try {
|
|
458
|
+
yield put(actions.setLoginState({
|
|
459
|
+
loading: true
|
|
460
|
+
}));
|
|
461
|
+
const {
|
|
462
|
+
name: inviteTokenTenantName
|
|
463
|
+
} = yield call(api.auth.verifyInviteToken, payload);
|
|
464
|
+
yield put(actions.setLoginState({
|
|
465
|
+
inviteTokenTenantName
|
|
466
|
+
}));
|
|
467
|
+
} catch (e) {
|
|
468
|
+
var _e$message2;
|
|
469
|
+
|
|
470
|
+
console.error(e);
|
|
471
|
+
yield put(actions.setLoginState({
|
|
472
|
+
inviteTokenError: (_e$message2 = e.message) != null ? _e$message2 : `We couldn't verify your invitation`
|
|
473
|
+
}));
|
|
474
|
+
} finally {
|
|
475
|
+
yield put(actions.setLoginState({
|
|
476
|
+
loading: false
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function* preLogin({
|
|
482
|
+
payload: {
|
|
483
|
+
email,
|
|
484
|
+
recaptchaToken,
|
|
485
|
+
invitationToken,
|
|
486
|
+
callback
|
|
487
|
+
}
|
|
488
|
+
}) {
|
|
489
|
+
yield put(actions.setLoginState({
|
|
490
|
+
loading: true
|
|
491
|
+
}));
|
|
492
|
+
|
|
493
|
+
try {
|
|
494
|
+
const onRedirectTo = yield select(({
|
|
495
|
+
auth: {
|
|
496
|
+
onRedirectTo
|
|
497
|
+
}
|
|
498
|
+
}) => onRedirectTo);
|
|
499
|
+
let {
|
|
500
|
+
address,
|
|
501
|
+
idpType
|
|
502
|
+
} = yield call(api.auth.preLoginV2, {
|
|
503
|
+
email
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
if (address) {
|
|
507
|
+
if (idpType === SamlVendors.Oidc && !address.includes('redirect_uri')) {
|
|
508
|
+
const {
|
|
509
|
+
routes: {
|
|
510
|
+
oidcRedirectUrl
|
|
511
|
+
}
|
|
512
|
+
} = yield select(({
|
|
513
|
+
auth: {
|
|
514
|
+
routes
|
|
515
|
+
}
|
|
516
|
+
}) => ({
|
|
517
|
+
routes
|
|
518
|
+
}));
|
|
519
|
+
address += `&redirect_uri=${window.location.origin}${oidcRedirectUrl}`;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
yield put(actions.setLoginState({
|
|
523
|
+
step: LoginStep.redirectToSSO,
|
|
524
|
+
loading: false,
|
|
525
|
+
ssoRedirectUrl: address
|
|
526
|
+
}));
|
|
527
|
+
setTimeout(() => {
|
|
528
|
+
onRedirectTo(address, {
|
|
529
|
+
refresh: true
|
|
530
|
+
});
|
|
531
|
+
}, 2000);
|
|
532
|
+
} else {
|
|
533
|
+
yield ssoPreloginFailed({
|
|
534
|
+
email,
|
|
535
|
+
recaptchaToken,
|
|
536
|
+
callback,
|
|
537
|
+
invitationToken
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
} catch (e) {
|
|
541
|
+
yield ssoPreloginFailed({
|
|
542
|
+
email,
|
|
543
|
+
recaptchaToken,
|
|
544
|
+
callback,
|
|
545
|
+
invitationToken
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function* ssoPreloginFailed(_ref3) {
|
|
551
|
+
let {
|
|
552
|
+
callback
|
|
553
|
+
} = _ref3,
|
|
554
|
+
body = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
555
|
+
|
|
556
|
+
const publicPolicy = yield select(({
|
|
557
|
+
auth: {
|
|
558
|
+
securityPolicyState: {
|
|
559
|
+
publicPolicy: {
|
|
560
|
+
policy: publicPolicy
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}) => publicPolicy);
|
|
565
|
+
|
|
566
|
+
if (!(publicPolicy != null && publicPolicy.authStrategy)) {
|
|
567
|
+
yield put(actions.setLoginState({
|
|
568
|
+
step: LoginStep.loginWithPassword,
|
|
569
|
+
loading: false
|
|
570
|
+
}));
|
|
571
|
+
callback == null ? void 0 : callback();
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
if ((publicPolicy == null ? void 0 : publicPolicy.authStrategy) === AuthStrategyEnum.EmailAndPassword) {
|
|
576
|
+
yield put(actions.setLoginState({
|
|
577
|
+
step: LoginStep.loginWithPassword,
|
|
578
|
+
loading: false
|
|
579
|
+
}));
|
|
580
|
+
callback == null ? void 0 : callback();
|
|
581
|
+
} else if ([AuthStrategyEnum.MagicLink, AuthStrategyEnum.Code, AuthStrategyEnum.SmsCode].includes(publicPolicy == null ? void 0 : publicPolicy.authStrategy)) {
|
|
582
|
+
yield put(actions.passwordlessPreLogin(_extends({}, body, {
|
|
583
|
+
type: publicPolicy == null ? void 0 : publicPolicy.authStrategy,
|
|
584
|
+
callback
|
|
585
|
+
})));
|
|
586
|
+
} else {
|
|
587
|
+
yield put(actions.setLoginState({
|
|
588
|
+
step: LoginStep.loginWithPassword,
|
|
589
|
+
loading: false
|
|
590
|
+
}));
|
|
591
|
+
callback == null ? void 0 : callback();
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function* postLogin({
|
|
596
|
+
payload
|
|
597
|
+
}) {
|
|
598
|
+
const {
|
|
599
|
+
onRedirectTo,
|
|
600
|
+
routes
|
|
601
|
+
} = yield select(({
|
|
602
|
+
auth: {
|
|
603
|
+
onRedirectTo,
|
|
604
|
+
routes
|
|
605
|
+
}
|
|
606
|
+
}) => ({
|
|
607
|
+
onRedirectTo,
|
|
608
|
+
routes
|
|
609
|
+
}));
|
|
610
|
+
yield put(actions.setLoginState({
|
|
611
|
+
loading: true
|
|
612
|
+
}));
|
|
613
|
+
|
|
614
|
+
try {
|
|
615
|
+
const user = yield call(api.auth.postLogin, payload);
|
|
616
|
+
ContextHolder.setAccessToken(user.accessToken);
|
|
617
|
+
ContextHolder.setUser(user);
|
|
618
|
+
yield put(actions.setState({
|
|
619
|
+
user: !!user.accessToken ? user : undefined,
|
|
620
|
+
isAuthenticated: !!user.accessToken
|
|
621
|
+
}));
|
|
622
|
+
yield afterAuthNavigation();
|
|
623
|
+
} catch (e) {
|
|
624
|
+
setTimeout(() => {
|
|
625
|
+
onRedirectTo(routes.authenticatedUrl);
|
|
626
|
+
}, 1000);
|
|
627
|
+
yield put(actions.setLoginState({
|
|
628
|
+
step: LoginStep.loginWithSSOFailed,
|
|
629
|
+
loading: false
|
|
630
|
+
}));
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
function* login({
|
|
635
|
+
payload: {
|
|
636
|
+
email,
|
|
637
|
+
password,
|
|
638
|
+
recaptchaToken,
|
|
639
|
+
invitationToken,
|
|
640
|
+
callback
|
|
641
|
+
}
|
|
642
|
+
}) {
|
|
643
|
+
yield put(actions.setLoginState({
|
|
644
|
+
loading: true
|
|
645
|
+
}));
|
|
646
|
+
|
|
647
|
+
try {
|
|
648
|
+
const user = yield call(api.auth.login, {
|
|
649
|
+
email,
|
|
650
|
+
password,
|
|
651
|
+
recaptchaToken,
|
|
652
|
+
invitationToken
|
|
653
|
+
});
|
|
654
|
+
ContextHolder.setAccessToken(user.accessToken);
|
|
655
|
+
ContextHolder.setUser(user);
|
|
656
|
+
let setMfaState = {};
|
|
657
|
+
let step = LoginStep.success;
|
|
658
|
+
|
|
659
|
+
if (user.mfaRequired && user.mfaToken) {
|
|
660
|
+
step = LoginStep.loginWithTwoFactor;
|
|
661
|
+
|
|
662
|
+
if (user.hasOwnProperty('mfaEnrolled') && !user.mfaEnrolled) {
|
|
663
|
+
setMfaState = {
|
|
664
|
+
mfaState: {
|
|
665
|
+
step: MFAStep.verify,
|
|
666
|
+
qrCode: user.qrCode,
|
|
667
|
+
recoveryCode: user.recoveryCode,
|
|
668
|
+
mfaToken: user.mfaToken,
|
|
669
|
+
loading: false
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
step = LoginStep.forceTwoFactor;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
const isAuthenticated = step === LoginStep.success && !!user.accessToken;
|
|
677
|
+
const loggedInUser = step === LoginStep.success && step === LoginStep.success ? user : undefined;
|
|
678
|
+
let allowRememberDevice = {
|
|
679
|
+
isAllowedToRemember: false,
|
|
680
|
+
mfaDeviceExpiration: 0
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
if (user.mfaRequired && user.mfaToken) {
|
|
684
|
+
allowRememberDevice = yield call(api.auth.checkIfAllowToRememberMfaDevice, user.mfaToken);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
const {
|
|
688
|
+
isAllowedToRemember,
|
|
689
|
+
mfaDeviceExpiration
|
|
690
|
+
} = allowRememberDevice;
|
|
691
|
+
yield put(actions.setState(_extends({
|
|
692
|
+
user: loggedInUser,
|
|
693
|
+
isAuthenticated
|
|
694
|
+
}, setMfaState, {
|
|
695
|
+
loginState: {
|
|
696
|
+
email,
|
|
697
|
+
loading: false,
|
|
698
|
+
error: undefined,
|
|
699
|
+
mfaToken: user.mfaToken,
|
|
700
|
+
step,
|
|
701
|
+
tenants: [],
|
|
702
|
+
tenantsLoading: true,
|
|
703
|
+
allowRememberMfaDevice: isAllowedToRemember,
|
|
704
|
+
mfaDeviceExpiration
|
|
705
|
+
}
|
|
706
|
+
})));
|
|
707
|
+
|
|
708
|
+
if (step === LoginStep.success) {
|
|
709
|
+
yield put(actions.loadTenants());
|
|
710
|
+
yield afterAuthNavigation();
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
callback == null ? void 0 : callback(true);
|
|
714
|
+
} catch (e) {
|
|
715
|
+
ContextHolder.setAccessToken(null);
|
|
716
|
+
ContextHolder.setUser(null);
|
|
717
|
+
yield put(actions.setLoginState({
|
|
718
|
+
email,
|
|
719
|
+
error: e.message,
|
|
720
|
+
loading: false
|
|
721
|
+
}));
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function* loginWithMfa({
|
|
726
|
+
payload: {
|
|
727
|
+
mfaToken,
|
|
728
|
+
value,
|
|
729
|
+
rememberDevice,
|
|
730
|
+
callback
|
|
731
|
+
}
|
|
732
|
+
}) {
|
|
733
|
+
yield put(actions.setLoginState({
|
|
734
|
+
loading: true
|
|
735
|
+
}));
|
|
736
|
+
|
|
737
|
+
try {
|
|
738
|
+
const user = yield call(api.auth.loginWithMfa, {
|
|
739
|
+
mfaToken,
|
|
740
|
+
value,
|
|
741
|
+
rememberDevice
|
|
742
|
+
});
|
|
743
|
+
const step = LoginStep.success;
|
|
744
|
+
yield put(actions.setState({
|
|
745
|
+
loginState: {
|
|
746
|
+
loading: false,
|
|
747
|
+
error: undefined,
|
|
748
|
+
step,
|
|
749
|
+
tenantsLoading: true,
|
|
750
|
+
tenants: []
|
|
751
|
+
},
|
|
752
|
+
user,
|
|
753
|
+
isAuthenticated: true
|
|
754
|
+
}));
|
|
755
|
+
yield put(actions.loadTenants());
|
|
756
|
+
callback == null ? void 0 : callback(true);
|
|
757
|
+
|
|
758
|
+
if (step === LoginStep.success) {
|
|
759
|
+
yield afterAuthNavigation();
|
|
760
|
+
}
|
|
761
|
+
} catch (e) {
|
|
762
|
+
yield put(actions.setLoginState({
|
|
763
|
+
error: e.message,
|
|
764
|
+
loading: false
|
|
765
|
+
}));
|
|
766
|
+
callback == null ? void 0 : callback(false, e);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
function* recoverMfa({
|
|
771
|
+
payload
|
|
772
|
+
}) {
|
|
773
|
+
yield put(actions.setLoginState({
|
|
774
|
+
loading: true
|
|
775
|
+
}));
|
|
776
|
+
|
|
777
|
+
try {
|
|
778
|
+
yield call(api.auth.recoverMfaToken, payload);
|
|
779
|
+
yield put(actions.setLoginState({
|
|
780
|
+
loading: false,
|
|
781
|
+
error: undefined,
|
|
782
|
+
step: LoginStep.preLogin
|
|
783
|
+
}));
|
|
784
|
+
yield put(actions.setState({
|
|
785
|
+
user: undefined,
|
|
786
|
+
isAuthenticated: false
|
|
787
|
+
}));
|
|
788
|
+
} catch (e) {
|
|
789
|
+
yield put(actions.setLoginState({
|
|
790
|
+
error: e.message,
|
|
791
|
+
loading: false
|
|
792
|
+
}));
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
function* logout({
|
|
797
|
+
payload
|
|
798
|
+
}) {
|
|
799
|
+
yield put(actions.setState({
|
|
800
|
+
isLoading: true
|
|
801
|
+
}));
|
|
802
|
+
|
|
803
|
+
try {
|
|
804
|
+
yield call(api.auth.logout);
|
|
805
|
+
} catch {}
|
|
806
|
+
|
|
807
|
+
yield put(actions.resetState());
|
|
808
|
+
yield put(actions.requestAuthorize(true));
|
|
809
|
+
payload == null ? void 0 : payload();
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
function* silentLogout({
|
|
813
|
+
payload
|
|
814
|
+
}) {
|
|
815
|
+
try {
|
|
816
|
+
yield call(api.auth.logout);
|
|
817
|
+
} catch {}
|
|
818
|
+
|
|
819
|
+
setTimeout(() => payload == null ? void 0 : payload(), 500);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export function* loginSagas() {
|
|
823
|
+
yield takeLeading(actions.requestAuthorize, requestAuthorize);
|
|
824
|
+
yield takeLeading(actions.requestAuthorizeSSR, requestAuthorizeSSR);
|
|
825
|
+
yield takeLeading(actions.requestHostedLoginAuthorize, requestHostedLoginAuthorize);
|
|
826
|
+
yield takeLeading(actions.handleHostedLoginCallback, handleHostedLoginCallback);
|
|
827
|
+
yield takeLeading(actions.preLogin, preLogin);
|
|
828
|
+
yield takeLeading(actions.postLogin, postLogin);
|
|
829
|
+
yield takeLeading(actions.login, login);
|
|
830
|
+
yield takeLeading(actions.logout, logout);
|
|
831
|
+
yield takeLeading(actions.silentLogout, silentLogout);
|
|
832
|
+
yield takeLeading(actions.loginWithMfa, loginWithMfa);
|
|
833
|
+
yield takeLeading(actions.recoverMfa, recoverMfa);
|
|
834
|
+
yield takeLeading(actions.passwordlessPreLogin, passwordlessPreLogin);
|
|
835
|
+
yield takeLeading(actions.passwordlessPostLogin, passwordlessPostLogin);
|
|
836
|
+
yield takeLeading(actions.verifyInviteToken, verifyInviteToken);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
function* requestAuthorizeMock({
|
|
840
|
+
payload: firstTime
|
|
841
|
+
}) {
|
|
842
|
+
if (firstTime) {
|
|
843
|
+
yield put(actions.setState({
|
|
844
|
+
isLoading: true
|
|
845
|
+
}));
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
const user = userDemo;
|
|
849
|
+
yield put(actions.loadTenants());
|
|
850
|
+
yield put(actions.setState({
|
|
851
|
+
user,
|
|
852
|
+
isAuthenticated: true,
|
|
853
|
+
isLoading: false
|
|
854
|
+
}));
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
export function* loginSagasMock() {
|
|
858
|
+
yield takeLeading(actions.requestAuthorize, requestAuthorizeMock);
|
|
859
|
+
yield takeLeading(actions.afterAuthNavigation, afterAuthNavigation);
|
|
860
|
+
}
|