@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
package/auth/index.js
CHANGED
|
@@ -1,4078 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const bytes = new Uint8Array(arraybuffer);
|
|
48
|
-
const len = bytes.length;
|
|
49
|
-
let i;
|
|
50
|
-
let base64url = '';
|
|
51
|
-
for (i = 0; i < len; i += 3) {
|
|
52
|
-
base64url += chars[bytes[i] >> 2];
|
|
53
|
-
base64url += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
|
|
54
|
-
base64url += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
|
|
55
|
-
base64url += chars[bytes[i + 2] & 63];
|
|
56
|
-
}
|
|
57
|
-
if (len % 3 === 2) {
|
|
58
|
-
base64url = base64url.substring(0, base64url.length - 1);
|
|
59
|
-
}
|
|
60
|
-
else if (len % 3 === 1) {
|
|
61
|
-
base64url = base64url.substring(0, base64url.length - 2);
|
|
62
|
-
}
|
|
63
|
-
return base64url;
|
|
64
|
-
};
|
|
65
|
-
const base64urlDecode = (base64string) => {
|
|
66
|
-
const bufferLength = base64string.length * 0.75;
|
|
67
|
-
let len = base64string.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
|
|
68
|
-
const bytes = new Uint8Array(bufferLength);
|
|
69
|
-
for (i = 0; i < len; i += 4) {
|
|
70
|
-
encoded1 = lookup[base64string.charCodeAt(i)];
|
|
71
|
-
encoded2 = lookup[base64string.charCodeAt(i + 1)];
|
|
72
|
-
encoded3 = lookup[base64string.charCodeAt(i + 2)];
|
|
73
|
-
encoded4 = lookup[base64string.charCodeAt(i + 3)];
|
|
74
|
-
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
|
|
75
|
-
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
|
|
76
|
-
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
|
|
77
|
-
}
|
|
78
|
-
return bytes.buffer;
|
|
79
|
-
};
|
|
80
|
-
const publicKeyCredentialToJSON = (pubKeyCred) => {
|
|
81
|
-
if (pubKeyCred instanceof Array) {
|
|
82
|
-
const arr = [];
|
|
83
|
-
for (const i of pubKeyCred) {
|
|
84
|
-
arr.push(publicKeyCredentialToJSON(i));
|
|
85
|
-
}
|
|
86
|
-
return arr;
|
|
87
|
-
}
|
|
88
|
-
else if (pubKeyCred instanceof ArrayBuffer) {
|
|
89
|
-
return base64urlEncode(pubKeyCred);
|
|
90
|
-
}
|
|
91
|
-
else if (pubKeyCred instanceof Object) {
|
|
92
|
-
const obj = {};
|
|
93
|
-
for (const key in pubKeyCred) {
|
|
94
|
-
obj[key] = publicKeyCredentialToJSON(pubKeyCred[key]);
|
|
95
|
-
}
|
|
96
|
-
return obj;
|
|
97
|
-
}
|
|
98
|
-
return pubKeyCred;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
var LoginStep;
|
|
102
|
-
(function (LoginStep) {
|
|
103
|
-
LoginStep["preLogin"] = "preLogin";
|
|
104
|
-
LoginStep["magicLinkPreLoginSuccess"] = "magicLinkPreLoginSuccess";
|
|
105
|
-
LoginStep["loginWithSmsOtc"] = "loginWithSmsOtc";
|
|
106
|
-
LoginStep["loginWithOtc"] = "loginWithOtc";
|
|
107
|
-
LoginStep["loginWithPassword"] = "loginWithPassword";
|
|
108
|
-
LoginStep["loginWithTwoFactor"] = "loginWithTwoFactor";
|
|
109
|
-
LoginStep["redirectToSSO"] = "redirectToSSO";
|
|
110
|
-
LoginStep["loginWithSSOFailed"] = "loginWithSSOFailed";
|
|
111
|
-
LoginStep["success"] = "success";
|
|
112
|
-
LoginStep["forceTwoFactor"] = "forceTwoFactor";
|
|
113
|
-
LoginStep["recoverTwoFactor"] = "recoverTwoFactor";
|
|
114
|
-
})(LoginStep || (LoginStep = {}));
|
|
115
|
-
var LoginFlow;
|
|
116
|
-
(function (LoginFlow) {
|
|
117
|
-
LoginFlow["Login"] = "login";
|
|
118
|
-
LoginFlow["RegisterQuickLogin"] = "registerQuickLogin";
|
|
119
|
-
})(LoginFlow || (LoginFlow = {}));
|
|
120
|
-
var QuickLoginStrategy;
|
|
121
|
-
(function (QuickLoginStrategy) {
|
|
122
|
-
QuickLoginStrategy["Internal"] = "internal";
|
|
123
|
-
QuickLoginStrategy["UsbKey"] = "usb-key";
|
|
124
|
-
QuickLoginStrategy["Android"] = "android";
|
|
125
|
-
QuickLoginStrategy["Sms"] = "sms";
|
|
126
|
-
})(QuickLoginStrategy || (QuickLoginStrategy = {}));
|
|
127
|
-
|
|
128
|
-
const loginState = {
|
|
129
|
-
flow: LoginFlow.Login,
|
|
130
|
-
step: LoginStep.preLogin,
|
|
131
|
-
loading: false,
|
|
132
|
-
email: '',
|
|
133
|
-
tenants: [],
|
|
134
|
-
};
|
|
135
|
-
const reducers$f = {
|
|
136
|
-
setLoginState: typeReducerForKey('loginState'),
|
|
137
|
-
resetLoginState: resetStateByKey('loginState', { loginState }),
|
|
138
|
-
};
|
|
139
|
-
const actions$g = {
|
|
140
|
-
requestAuthorize: createAction(`${authStoreName}/requestAuthorize`, (payload = false) => ({ payload })),
|
|
141
|
-
requestAuthorizeSSR: createAction(`${authStoreName}/requestAuthorizeSSR`, (payload) => ({ payload })),
|
|
142
|
-
requestHostedLoginAuthorize: createAction(`${authStoreName}/requestHostedLoginAuthorize`),
|
|
143
|
-
handleHostedLoginCallback: createAction(`${authStoreName}/handleHostedLoginCallback`, (payload) => ({ payload })),
|
|
144
|
-
afterAuthNavigation: createAction(`${authStoreName}/afterAuthNavigation`),
|
|
145
|
-
preLogin: createAction(`${authStoreName}/preLogin`, (payload) => ({ payload })),
|
|
146
|
-
postLogin: createAction(`${authStoreName}/postLogin`, (payload) => ({ payload })),
|
|
147
|
-
login: createAction(`${authStoreName}/login`, (payload) => ({ payload })),
|
|
148
|
-
loginWithMfa: createAction(`${authStoreName}/loginWithMfa`, (payload) => ({ payload })),
|
|
149
|
-
recoverMfa: createAction(`${authStoreName}/recoverMfa`, (payload) => ({ payload })),
|
|
150
|
-
logout: createAction(`${authStoreName}/logout`, (payload) => ({ payload })),
|
|
151
|
-
silentLogout: createAction(`${authStoreName}/silentLogout`, (payload) => ({ payload })),
|
|
152
|
-
checkIfAllowToRememberMfaDevice: createAction(`${authStoreName}/checkIfAllowToRememberMfaDevice`, (payload) => ({ payload })),
|
|
153
|
-
passwordlessPreLogin: createAction(`${authStoreName}/passwordlessPreLogin`, (payload) => ({ payload })),
|
|
154
|
-
passwordlessPostLogin: createAction(`${authStoreName}/passwordlessPostLogin`, (payload) => ({ payload })),
|
|
155
|
-
verifyInviteToken: createAction(`${authStoreName}/verifyInviteToken`, (payload) => ({ payload })),
|
|
156
|
-
webAuthnPrelogin: createAction(`${authStoreName}/webAuthnPrelogin`, (payload) => ({ payload })),
|
|
157
|
-
webAuthnPostLogin: createAction(`${authStoreName}/webAuthnPostLogin`, (payload) => ({ payload })),
|
|
158
|
-
webAuthnCreateNewDeviceSession: createAction(`${authStoreName}/webAuthnCreateNewDeviceSession`, (payload) => ({ payload })),
|
|
159
|
-
webAuthnVerifyNewDeviceSession: createAction(`${authStoreName}/webAuthnVerifyNewDeviceSession`, (payload) => ({ payload })),
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
var ActivateAccountStep;
|
|
163
|
-
(function (ActivateAccountStep) {
|
|
164
|
-
ActivateAccountStep["activating"] = "activating";
|
|
165
|
-
ActivateAccountStep["success"] = "success";
|
|
166
|
-
ActivateAccountStep["resend"] = "resend";
|
|
167
|
-
ActivateAccountStep["activatingForm"] = "activatingForm";
|
|
168
|
-
})(ActivateAccountStep || (ActivateAccountStep = {}));
|
|
169
|
-
|
|
170
|
-
const activateState = {
|
|
171
|
-
step: ActivateAccountStep.activating,
|
|
172
|
-
loading: false,
|
|
173
|
-
resentEmail: false,
|
|
174
|
-
activationStrategy: {
|
|
175
|
-
loading: false,
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
const reducers$e = {
|
|
179
|
-
setActivateState: typeReducerForKey('activateState'),
|
|
180
|
-
resetActivateState: resetStateByKey('activateState', { activateState }),
|
|
181
|
-
setActivateStrategyState: typeReducerNestedKey('activateState', 'activationStrategy'),
|
|
182
|
-
};
|
|
183
|
-
const actions$f = {
|
|
184
|
-
activateAccount: createAction(`${authStoreName}/activateAccount`, (payload) => ({ payload })),
|
|
185
|
-
preActivateAccount: createAction(`${authStoreName}/preActivateAccount`, (payload) => ({ payload })),
|
|
186
|
-
getActivateAccountStrategy: createAction(`${authStoreName}/getActivateAccountStrategy`, (payload) => ({ payload })),
|
|
187
|
-
resendActivationEmail: createAction(`${authStoreName}/resendActivationEmail`, (payload) => ({
|
|
188
|
-
payload,
|
|
189
|
-
})),
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
var AcceptInvitationStep;
|
|
193
|
-
(function (AcceptInvitationStep) {
|
|
194
|
-
AcceptInvitationStep["validate"] = "validate";
|
|
195
|
-
AcceptInvitationStep["invalid"] = "invalid";
|
|
196
|
-
AcceptInvitationStep["pending"] = "pending";
|
|
197
|
-
AcceptInvitationStep["success"] = "success";
|
|
198
|
-
AcceptInvitationStep["failed"] = "failed";
|
|
199
|
-
})(AcceptInvitationStep || (AcceptInvitationStep = {}));
|
|
200
|
-
|
|
201
|
-
const acceptInvitationState = {
|
|
202
|
-
step: AcceptInvitationStep.validate,
|
|
203
|
-
};
|
|
204
|
-
const reducers$d = {
|
|
205
|
-
setAcceptInvitationState: typeReducerForKey('acceptInvitationState'),
|
|
206
|
-
resetAcceptInvitationState: resetStateByKey('acceptInvitationState', {
|
|
207
|
-
acceptInvitationState,
|
|
208
|
-
}),
|
|
209
|
-
};
|
|
210
|
-
const actions$e = {
|
|
211
|
-
acceptInvitation: createAction(`${authStoreName}/acceptInvitation`, (payload) => ({ payload })),
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
var ForgotPasswordStep;
|
|
215
|
-
(function (ForgotPasswordStep) {
|
|
216
|
-
ForgotPasswordStep["forgotPassword"] = "forgotPassword";
|
|
217
|
-
ForgotPasswordStep["success"] = "success";
|
|
218
|
-
})(ForgotPasswordStep || (ForgotPasswordStep = {}));
|
|
219
|
-
|
|
220
|
-
const forgotPasswordState = {
|
|
221
|
-
step: ForgotPasswordStep.forgotPassword,
|
|
222
|
-
loading: false,
|
|
223
|
-
email: '',
|
|
224
|
-
passwordConfig: null,
|
|
225
|
-
};
|
|
226
|
-
const reducers$c = {
|
|
227
|
-
setForgotPasswordState: typeReducerForKey('forgotPasswordState'),
|
|
228
|
-
resetForgotPasswordState: resetStateByKey('forgotPasswordState', { forgotPasswordState }),
|
|
229
|
-
};
|
|
230
|
-
const actions$d = {
|
|
231
|
-
forgotPassword: createAction(`${authStoreName}/forgotPassword`, (payload) => ({ payload })),
|
|
232
|
-
resetPassword: createAction(`${authStoreName}/resetPassword`, (payload) => ({ payload })),
|
|
233
|
-
loadPasswordConfig: createAction(`${authStoreName}/loadPasswordConfig`, (payload) => ({
|
|
234
|
-
payload,
|
|
235
|
-
})),
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
var ResetPhoneNumberStep;
|
|
239
|
-
(function (ResetPhoneNumberStep) {
|
|
240
|
-
ResetPhoneNumberStep["ResetPhoneNumber"] = "ResetPhoneNumber";
|
|
241
|
-
ResetPhoneNumberStep["VerifyResetPhoneNumber"] = "VerifyResetPhoneNumber";
|
|
242
|
-
ResetPhoneNumberStep["ChangePhoneNumber"] = "ChangePhoneNumber";
|
|
243
|
-
})(ResetPhoneNumberStep || (ResetPhoneNumberStep = {}));
|
|
244
|
-
|
|
245
|
-
const resetPhoneNumberState = {
|
|
246
|
-
step: ResetPhoneNumberStep.ResetPhoneNumber,
|
|
247
|
-
loading: false,
|
|
248
|
-
};
|
|
249
|
-
const reducers$b = {
|
|
250
|
-
setResetPhoneNumberState: typeReducerForKey('resetPhoneNumberState'),
|
|
251
|
-
resetResetPhoneNumberState: resetStateByKey('resetPhoneNumberState', { resetPhoneNumberState }),
|
|
252
|
-
};
|
|
253
|
-
const actions$c = {
|
|
254
|
-
resetPhoneNumber: createAction(`${authStoreName}/resetPhoneNumber`, (payload) => ({ payload })),
|
|
255
|
-
verifyResetPhoneNumber: createAction(`${authStoreName}/verifyResetPhoneNumber`, (payload) => ({ payload })),
|
|
256
|
-
changePhoneNumber: createAction(`${authStoreName}/changePhoneNumber`, (payload) => ({ payload })),
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
const ssoState = {
|
|
260
|
-
firstLoad: true,
|
|
261
|
-
loading: true,
|
|
262
|
-
saving: false,
|
|
263
|
-
errors: {},
|
|
264
|
-
loaders: {},
|
|
265
|
-
ssoConfigurations: []
|
|
266
|
-
};
|
|
267
|
-
const reducers$a = {
|
|
268
|
-
setSSOLoader: loadersReducerForKey('ssoState'),
|
|
269
|
-
setSSOError: errorsReducerForKey('ssoState'),
|
|
270
|
-
setSSOState: typeReducerForKey('ssoState'),
|
|
271
|
-
resetSSOState: resetStateByKey('ssoState', { ssoState }),
|
|
272
|
-
};
|
|
273
|
-
const actions$b = {
|
|
274
|
-
loadSSOConfigurationsV2: createAction(`${authStoreName}/loadSSOConfigurationsV2`),
|
|
275
|
-
saveSSOConfigurationV2: createAction(`${authStoreName}/saveSSOConfigurationV2`, (payload) => ({ payload })),
|
|
276
|
-
updateSSOConfiguration: createAction(`${authStoreName}/updateSSOConfiguration`, (payload) => ({ payload })),
|
|
277
|
-
deleteSSOConfiguration: createAction(`${authStoreName}/deleteSSOConfiguration`, (payload) => ({ payload })),
|
|
278
|
-
saveSSODomain: createAction(`${authStoreName}/saveSSODomain`, (payload) => ({ payload })),
|
|
279
|
-
deleteSSODomain: createAction(`${authStoreName}/deleteSSODomain`, (payload) => ({ payload })),
|
|
280
|
-
validateSSODomainV2: createAction(`${authStoreName}/validateSSODomainV2`, (payload) => ({ payload })),
|
|
281
|
-
setSSODefaultRoles: createAction(`${authStoreName}/setSSODefaultRoles`, (payload) => ({ payload })),
|
|
282
|
-
setSSOGroups: createAction(`${authStoreName}/setSSOGroups`, (payload) => ({ payload })),
|
|
283
|
-
updateSSOGroups: createAction(`${authStoreName}/updateSSOGroups`, (payload) => ({ payload })),
|
|
284
|
-
saveSSOConfigurationByMetadata: createAction(`${authStoreName}/saveSSOConfigurationByMetadata`, (payload) => ({ payload })),
|
|
285
|
-
updateSSOConfigurationByMetadata: createAction(`${authStoreName}/updateSSOConfigurationByMetadata`, (payload) => ({ payload })),
|
|
286
|
-
loadSSOConfigurations: createAction(`${authStoreName}/loadSSOConfigurations`),
|
|
287
|
-
loadSSOAuthorizationRoles: createAction(`${authStoreName}/loadSSOAuthorizationRoles`),
|
|
288
|
-
saveSSOConfigurations: createAction(`${authStoreName}/saveSSOConfigurations`, (payload) => ({ payload })),
|
|
289
|
-
// NOTE: use withCallback in case of promise response
|
|
290
|
-
saveSSOConfigurationsFile: createAction(`${authStoreName}/saveSSOConfigurationsFile`, (payload) => ({
|
|
291
|
-
payload,
|
|
292
|
-
})),
|
|
293
|
-
saveSSOConfigurationsFileWithCallback: createAction(`${authStoreName}/saveSSOConfigurationsFileWithCallback`, (payload) => ({ payload })),
|
|
294
|
-
validateSSODomain: createAction(`${authStoreName}/validateSSODomain`, (payload) => ({ payload })),
|
|
295
|
-
updateSSOAuthorizationRoles: createAction(`${authStoreName}/updateSSOAuthorizationRoles`, (payload) => ({ payload })),
|
|
296
|
-
deleteSamlGroup: createAction(`${authStoreName}/deleteSamlGroup`, (payload) => ({ payload })),
|
|
297
|
-
createSamlGroup: createAction(`${authStoreName}/createSamlGroup`, (payload) => ({ payload })),
|
|
298
|
-
oidcPostlogin: createAction(`${authStoreName}/oidcPostlogin`, (payload) => ({
|
|
299
|
-
payload,
|
|
300
|
-
})),
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
const profileState = {
|
|
304
|
-
loading: false,
|
|
305
|
-
error: null,
|
|
306
|
-
};
|
|
307
|
-
const reducers$9 = {
|
|
308
|
-
setProfileState: typeReducerForKey('profileState'),
|
|
309
|
-
resetProfileState: resetStateByKey('profileState', { profileState }),
|
|
310
|
-
};
|
|
311
|
-
const actions$a = {
|
|
312
|
-
loadProfile: createAction(`${authStoreName}/loadProfile`),
|
|
313
|
-
saveProfile: createAction(`${authStoreName}/saveProfile`, (payload) => ({ payload })),
|
|
314
|
-
changePassword: createAction(`${authStoreName}/changePassword`, (payload) => ({
|
|
315
|
-
payload,
|
|
316
|
-
})),
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
var MFAStep;
|
|
320
|
-
(function (MFAStep) {
|
|
321
|
-
MFAStep["verify"] = "verify";
|
|
322
|
-
MFAStep["recoveryCode"] = "recoveryCode";
|
|
323
|
-
})(MFAStep || (MFAStep = {}));
|
|
324
|
-
|
|
325
|
-
const mfaState = {
|
|
326
|
-
step: MFAStep.verify,
|
|
327
|
-
loading: false,
|
|
328
|
-
};
|
|
329
|
-
const reducers$8 = {
|
|
330
|
-
setMfaState: typeReducerForKey('mfaState'),
|
|
331
|
-
resetMfaState: resetStateByKey('mfaState', { mfaState }),
|
|
332
|
-
};
|
|
333
|
-
const actions$9 = {
|
|
334
|
-
enrollMfa: createAction(`${authStoreName}/enrollMfa`),
|
|
335
|
-
verifyMfa: createAction(`${authStoreName}/verifyMfa`, (payload) => ({
|
|
336
|
-
payload,
|
|
337
|
-
})),
|
|
338
|
-
verifyMfaAfterForce: createAction(`${authStoreName}/verifyMfaAfterForce`, (payload) => ({
|
|
339
|
-
payload,
|
|
340
|
-
})),
|
|
341
|
-
disableMfa: createAction(`${authStoreName}/disableMfa`, (payload) => ({ payload })),
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
const teamState = {
|
|
345
|
-
loaders: {},
|
|
346
|
-
pageOffset: 0,
|
|
347
|
-
pageSize: 20,
|
|
348
|
-
errors: {},
|
|
349
|
-
users: [],
|
|
350
|
-
allUsers: [],
|
|
351
|
-
roles: [],
|
|
352
|
-
permissions: [],
|
|
353
|
-
totalPages: 0,
|
|
354
|
-
filter: [],
|
|
355
|
-
sort: [],
|
|
356
|
-
allUsersQueryParams: {
|
|
357
|
-
_filter: null,
|
|
358
|
-
_offset: 0,
|
|
359
|
-
_limit: 20,
|
|
360
|
-
_order: 'DESC',
|
|
361
|
-
_sortBy: 'name',
|
|
362
|
-
},
|
|
363
|
-
addUserDialogState: {
|
|
364
|
-
loading: false,
|
|
365
|
-
open: false,
|
|
366
|
-
},
|
|
367
|
-
deleteUserDialogState: {
|
|
368
|
-
loading: false,
|
|
369
|
-
open: false,
|
|
370
|
-
},
|
|
371
|
-
lockUserDialogState: {
|
|
372
|
-
loading: false,
|
|
373
|
-
open: false,
|
|
374
|
-
},
|
|
375
|
-
};
|
|
376
|
-
const reducers$7 = {
|
|
377
|
-
setTeamLoader: loadersReducerForKey('teamState'),
|
|
378
|
-
setTeamError: errorsReducerForKey('teamState'),
|
|
379
|
-
setTeamState: typeReducerForKey('teamState'),
|
|
380
|
-
resetTeamState: resetStateByKey('teamState', { teamState }),
|
|
381
|
-
};
|
|
382
|
-
const actions$8 = {
|
|
383
|
-
loadUsers: createAction(`${authStoreName}/loadUsers`, (payload) => ({ payload })),
|
|
384
|
-
loadAllSubTenantsUsers: createAction(`${authStoreName}/loadAllSubTenantsUsers`, (payload) => ({ payload })),
|
|
385
|
-
loadRoles: createAction(`${authStoreName}/loadRoles`, (payload) => ({ payload })),
|
|
386
|
-
addUser: createAction(`${authStoreName}/addUser`, (payload) => ({ payload })),
|
|
387
|
-
addUserToSubTenants: createAction(`${authStoreName}/addUserToSubTenants`, (payload) => ({ payload })),
|
|
388
|
-
updateUser: createAction(`${authStoreName}/updateUser`, (payload) => ({
|
|
389
|
-
payload,
|
|
390
|
-
})),
|
|
391
|
-
deleteUser: createAction(`${authStoreName}/deleteUser`, (payload) => ({ payload })),
|
|
392
|
-
setUserRolesForSubTenants: createAction(`${authStoreName}/setUserRolesForSubTenants`, (payload) => ({ payload })),
|
|
393
|
-
deleteUserFromSubTenants: createAction(`${authStoreName}/deleteUserFromSubTenants`, (payload) => ({ payload })),
|
|
394
|
-
lockUser: createAction(`${authStoreName}/lockUser`, (payload) => ({ payload })),
|
|
395
|
-
resendActivationLink: createAction(`${authStoreName}/resendActivationLink`, (payload) => ({ payload })),
|
|
396
|
-
resendInvitationLink: createAction(`${authStoreName}/resendInvitationLink`, (payload) => ({ payload })),
|
|
397
|
-
getInvitationLink: createAction(`${authStoreName}/getInvitationLink`),
|
|
398
|
-
createInvitationLink: createAction(`${authStoreName}/createInvitationLink`, (payload) => ({ payload })),
|
|
399
|
-
updateInvitationLink: createAction(`${authStoreName}/updateInvitationLink`, (payload) => ({ payload })),
|
|
400
|
-
deleteInvitationLink: createAction(`${authStoreName}/deleteInvitationLink`, (payload) => ({ payload })),
|
|
401
|
-
openAddUserDialog: createAction(`${authStoreName}/openAddUserDialog`, (payload) => ({ payload })),
|
|
402
|
-
closeAddUserDialog: createAction(`${authStoreName}/closeAddUserDialog`, (payload) => ({ payload })),
|
|
403
|
-
openDeleteUserDialog: createAction(`${authStoreName}/openDeleteUserDialog`, (payload) => ({
|
|
404
|
-
payload,
|
|
405
|
-
})),
|
|
406
|
-
closeDeleteUserDialog: createAction(`${authStoreName}/closeDeleteUserDialog`, (payload) => ({ payload })),
|
|
407
|
-
openLockUserDialog: createAction(`${authStoreName}/openLockUserDialog`, (payload) => ({
|
|
408
|
-
payload,
|
|
409
|
-
})),
|
|
410
|
-
closeLockUserDialog: createAction(`${authStoreName}/closeLockUserDialog`, (payload) => ({ payload })),
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
const socialLoginState = {
|
|
414
|
-
firstLoad: true,
|
|
415
|
-
loading: false,
|
|
416
|
-
error: '',
|
|
417
|
-
};
|
|
418
|
-
const reducers$6 = {
|
|
419
|
-
setSocialLoginsState: typeReducerForKey('socialLoginState'),
|
|
420
|
-
resetSocialLoginsState: resetStateByKey('socialLoginState', { socialLoginState }),
|
|
421
|
-
};
|
|
422
|
-
const actions$7 = {
|
|
423
|
-
loadSocialLoginsConfiguration: createAction(`${authStoreName}/loadSocialLoginsConfiguration`),
|
|
424
|
-
loadSocialLoginsConfigurationV2: createAction(`${authStoreName}/loadSocialLoginsConfigurationV2`),
|
|
425
|
-
loginViaSocialLogin: createAction(`${authStoreName}/loginViaSocialLogin`, (payload) => ({
|
|
426
|
-
payload,
|
|
427
|
-
})),
|
|
428
|
-
setSocialLoginError: createAction(`${authStoreName}/setSocialLoginError`, (payload) => ({
|
|
429
|
-
payload,
|
|
430
|
-
})),
|
|
431
|
-
};
|
|
432
|
-
|
|
433
|
-
var SignUpStage;
|
|
434
|
-
(function (SignUpStage) {
|
|
435
|
-
SignUpStage["SignUp"] = "SignUp";
|
|
436
|
-
SignUpStage["SignUpSuccess"] = "SignUpSuccess";
|
|
437
|
-
})(SignUpStage || (SignUpStage = {}));
|
|
438
|
-
|
|
439
|
-
const signUpState = {
|
|
440
|
-
loading: false,
|
|
441
|
-
allowSignUps: false,
|
|
442
|
-
allowNotVerifiedUsersLogin: false,
|
|
443
|
-
firstLoad: true,
|
|
444
|
-
stage: SignUpStage.SignUp,
|
|
445
|
-
};
|
|
446
|
-
const reducers$5 = {
|
|
447
|
-
setSignUpState: typeReducerForKey('signUpState'),
|
|
448
|
-
resetSignUpState: resetStateByKey('signUpState', { signUpState }),
|
|
449
|
-
};
|
|
450
|
-
const actions$6 = {
|
|
451
|
-
signUpUser: createAction(`${authStoreName}/signUpUser`, (payload) => ({ payload })),
|
|
452
|
-
resetSignUpStateSoft: createAction(`${authStoreName}/resetSignUpStateSoft`),
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
const apiTokensState = {
|
|
456
|
-
apiTokenType: null,
|
|
457
|
-
searchValue: '',
|
|
458
|
-
showAddTokenDialog: false,
|
|
459
|
-
createdByUserIdColumn: 'show',
|
|
460
|
-
deleteTokenDialog: {
|
|
461
|
-
open: false,
|
|
462
|
-
clientId: '',
|
|
463
|
-
},
|
|
464
|
-
successDialog: {
|
|
465
|
-
open: false,
|
|
466
|
-
secret: '',
|
|
467
|
-
clientId: '',
|
|
468
|
-
},
|
|
469
|
-
loaders: {},
|
|
470
|
-
apiTokensDataTenant: [],
|
|
471
|
-
apiTokensDataUser: [],
|
|
472
|
-
roles: [],
|
|
473
|
-
permissions: [],
|
|
474
|
-
errors: {},
|
|
475
|
-
};
|
|
476
|
-
const reducers$4 = {
|
|
477
|
-
setApiTokensLoader: loadersReducerForKey('apiTokensState'),
|
|
478
|
-
setApiTokensError: errorsReducerForKey('apiTokensState'),
|
|
479
|
-
setApiTokensState: typeReducerForKey('apiTokensState'),
|
|
480
|
-
resetApiTokensState: resetStateByKey('apiTokensState', { apiTokensState }),
|
|
481
|
-
};
|
|
482
|
-
const actions$5 = {
|
|
483
|
-
loadApiTokens: createAction(`${authStoreName}/loadApiTokens`, (payload) => ({
|
|
484
|
-
payload,
|
|
485
|
-
})),
|
|
486
|
-
initApiTokensData: createAction(`${authStoreName}/initApiTokensData`, (payload) => ({ payload })),
|
|
487
|
-
addTenantApiToken: createAction(`${authStoreName}/addTenantApiToken`, (payload) => ({
|
|
488
|
-
payload,
|
|
489
|
-
})),
|
|
490
|
-
addUserApiToken: createAction(`${authStoreName}/addUserApiToken`, (payload) => ({ payload })),
|
|
491
|
-
deleteUserApiToken: createAction(`${authStoreName}/deleteUserApiToken`, (payload) => ({ payload })),
|
|
492
|
-
deleteTenantApiToken: createAction(`${authStoreName}/deleteTenantApiToken`, (payload) => ({ payload })),
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
const securityPolicyState = {
|
|
496
|
-
globalPolicy: {
|
|
497
|
-
loading: true,
|
|
498
|
-
},
|
|
499
|
-
publicPolicy: {
|
|
500
|
-
loading: false,
|
|
501
|
-
},
|
|
502
|
-
vendorMfaPolicy: {
|
|
503
|
-
loading: true,
|
|
504
|
-
},
|
|
505
|
-
mfaPolicy: {
|
|
506
|
-
loading: true,
|
|
507
|
-
},
|
|
508
|
-
lockoutPolicy: {
|
|
509
|
-
loading: true,
|
|
510
|
-
},
|
|
511
|
-
captchaPolicy: {
|
|
512
|
-
loading: true,
|
|
513
|
-
},
|
|
514
|
-
passwordHistoryPolicy: {
|
|
515
|
-
loading: true,
|
|
516
|
-
},
|
|
517
|
-
passwordPolicy: {
|
|
518
|
-
loading: true,
|
|
519
|
-
},
|
|
520
|
-
publicAuthStrategyPolicy: {
|
|
521
|
-
loading: true,
|
|
522
|
-
},
|
|
523
|
-
};
|
|
524
|
-
const reducers$3 = {
|
|
525
|
-
setSecurityPolicyState: typeReducerForKey('securityPolicyState'),
|
|
526
|
-
setSecurityPolicyGlobalState: typeReducerNestedKey('securityPolicyState', 'globalPolicy'),
|
|
527
|
-
setSecurityPolicyPublicState: typeReducerNestedKey('securityPolicyState', 'publicPolicy'),
|
|
528
|
-
setSecurityPolicyAuthStrategyPublicState: typeReducerNestedKey('securityPolicyState', 'publicAuthStrategyPolicy'),
|
|
529
|
-
setSecurityPolicyMfaState: typeReducerNestedKey('securityPolicyState', 'mfaPolicy'),
|
|
530
|
-
setSecurityPolicyVendorMfaState: typeReducerNestedKey('securityPolicyState', 'vendorMfaPolicy'),
|
|
531
|
-
setSecurityPolicyLockoutState: typeReducerNestedKey('securityPolicyState', 'lockoutPolicy'),
|
|
532
|
-
setSecurityPolicyCaptchaState: typeReducerNestedKey('securityPolicyState', 'captchaPolicy'),
|
|
533
|
-
setSecurityPolicyPasswordHistoryState: typeReducerNestedKey('securityPolicyState', 'passwordHistoryPolicy'),
|
|
534
|
-
setSecurityPolicyPasswordState: typeReducerNestedKey('securityPolicyState', 'passwordPolicy'),
|
|
535
|
-
resetSecurityPolicyState: resetStateByKey('securityPolicyState', { securityPolicyState }),
|
|
536
|
-
};
|
|
537
|
-
const actions$4 = {
|
|
538
|
-
loadSecurityPolicy: createAction(`${authStoreName}/loadSecurityPolicy`),
|
|
539
|
-
loadPublicSecurityPolicy: createAction(`${authStoreName}/loadPublicSecurityPolicy`),
|
|
540
|
-
loadSecurityPolicyMfa: createAction(`${authStoreName}/loadSecurityPolicyMfa`),
|
|
541
|
-
loadSecurityPolicyVendorMfa: createAction(`${authStoreName}/loadSecurityPolicyVendorMfa`),
|
|
542
|
-
saveSecurityPolicyMfa: createAction(`${authStoreName}/saveSecurityPolicyMfa`, (payload) => ({ payload })),
|
|
543
|
-
loadSecurityPolicyLockout: createAction(`${authStoreName}/loadSecurityPolicyLockout`),
|
|
544
|
-
saveSecurityPolicyLockout: createAction(`${authStoreName}/saveSecurityPolicyLockout`, (payload) => ({ payload })),
|
|
545
|
-
loadSecurityPolicyCaptcha: createAction(`${authStoreName}/loadSecurityPolicyCaptcha`),
|
|
546
|
-
loadSecurityPolicyPasswordHistory: createAction(`${authStoreName}/loadSecurityPolicyPasswordHistory`),
|
|
547
|
-
saveSecurityPolicyPasswordHistory: createAction(`${authStoreName}/saveSecurityPolicyPasswordHistory`, (payload) => ({ payload })),
|
|
548
|
-
loadVendorPasswordConfig: createAction(`${authStoreName}/loadVendorPasswordConfig`),
|
|
549
|
-
loadPublicAuthStrategiesPolicy: createAction(`${authStoreName}/loadPublicAuthStrategiesPolicy`),
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
const accountSettingsState = {
|
|
553
|
-
loading: false,
|
|
554
|
-
};
|
|
555
|
-
const reducers$2 = {
|
|
556
|
-
setAccountSettingsState: typeReducerForKey('accountSettingsState'),
|
|
557
|
-
resetAccountSettingsState: resetStateByKey('accountSettingsState', { accountSettingsState }),
|
|
558
|
-
};
|
|
559
|
-
const actions$3 = {
|
|
560
|
-
loadAccountSettings: createAction(`${authStoreName}/loadAccountSettings`, (payload) => ({ payload })),
|
|
561
|
-
saveAccountSettings: createAction(`${authStoreName}/saveAccountSettings`, (payload) => ({ payload })),
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
const tenantsState = {
|
|
565
|
-
tenants: [],
|
|
566
|
-
subTenants: [],
|
|
567
|
-
loading: true,
|
|
568
|
-
tenantTree: null,
|
|
569
|
-
};
|
|
570
|
-
const reducers$1 = {
|
|
571
|
-
setTenantsState: typeReducerForKey('tenantsState'),
|
|
572
|
-
resetTenantsState: resetStateByKey('tenantsState', { tenantsState }),
|
|
573
|
-
};
|
|
574
|
-
const actions$2 = {
|
|
575
|
-
switchTenant: createAction(`${authStoreName}/switchTenant`, (payload) => ({ payload })),
|
|
576
|
-
loadTenants: createAction(`${authStoreName}/loadTenants`, (payload) => ({
|
|
577
|
-
payload,
|
|
578
|
-
})),
|
|
579
|
-
loadSubTenants: createAction(`${authStoreName}/loadSubTenants`, (payload) => ({
|
|
580
|
-
payload,
|
|
581
|
-
})),
|
|
582
|
-
loadSubTenantsTree: createAction(`${authStoreName}/loadSubTenantsTree`, (payload) => ({
|
|
583
|
-
payload,
|
|
584
|
-
})),
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
const rolesState = {
|
|
588
|
-
loading: false,
|
|
589
|
-
roles: [],
|
|
590
|
-
permissions: [],
|
|
591
|
-
permissionCategories: [],
|
|
592
|
-
};
|
|
593
|
-
const reducers = {
|
|
594
|
-
setRolesState: typeReducerForKey('rolesState'),
|
|
595
|
-
resetRolesState: resetStateByKey('rolesState', { rolesState }),
|
|
596
|
-
};
|
|
597
|
-
const actions$1 = {
|
|
598
|
-
loadRolesAndPermissions: createAction(`${authStoreName}/loadRoles`, (payload) => ({ payload })),
|
|
599
|
-
addRole: createAction(`${authStoreName}/addRole`, (payload) => ({ payload })),
|
|
600
|
-
updateRole: createAction(`${authStoreName}/updateRole`, (payload) => ({ payload })),
|
|
601
|
-
deleteRole: createAction(`${authStoreName}/deleteRole`, (payload) => ({ payload })),
|
|
602
|
-
attachPermissionsToRole: createAction(`${authStoreName}/attachPermissionsToRole`, (payload) => ({ payload })),
|
|
603
|
-
attachPermissionToRoles: createAction(`${authStoreName}/attachPermissionToRoles`, (payload) => ({ payload })),
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
const reinitializeState = {
|
|
607
|
-
isAuthenticated: false,
|
|
608
|
-
isLoading: true,
|
|
609
|
-
isSSOAuth: false,
|
|
610
|
-
user: null,
|
|
611
|
-
signUpState,
|
|
612
|
-
loginState,
|
|
613
|
-
activateState,
|
|
614
|
-
acceptInvitationState,
|
|
615
|
-
forgotPasswordState,
|
|
616
|
-
ssoState,
|
|
617
|
-
profileState,
|
|
618
|
-
mfaState,
|
|
619
|
-
teamState,
|
|
620
|
-
socialLoginState,
|
|
621
|
-
apiTokensState,
|
|
622
|
-
securityPolicyState,
|
|
623
|
-
accountSettingsState,
|
|
624
|
-
tenantsState,
|
|
625
|
-
rolesState,
|
|
626
|
-
resetPhoneNumberState
|
|
627
|
-
};
|
|
628
|
-
const initialState = Object.assign({ routes: {
|
|
629
|
-
authenticatedUrl: '/',
|
|
630
|
-
loginUrl: '/account/login',
|
|
631
|
-
logoutUrl: '/account/logout',
|
|
632
|
-
activateUrl: '/account/activate',
|
|
633
|
-
acceptInvitationUrl: '/account/invitation/accept',
|
|
634
|
-
forgetPasswordUrl: '/account/forget-password',
|
|
635
|
-
resetPhoneNumberUrl: '/account/reset-phone-number',
|
|
636
|
-
resetPasswordUrl: '/account/reset-password',
|
|
637
|
-
socialLoginCallbackUrl: '/account/social/success',
|
|
638
|
-
signUpUrl: '/account/sign-up',
|
|
639
|
-
oidcRedirectUrl: '/account/oidc/callback',
|
|
640
|
-
samlCallbackUrl: '/account/saml/callback',
|
|
641
|
-
magicLinkCallbackUrl: '/account/login/magic-link',
|
|
642
|
-
hostedLoginRedirectUrl: '/oauth/callback'
|
|
643
|
-
}, onRedirectTo: () => { } }, reinitializeState);
|
|
644
|
-
|
|
645
|
-
const { reducer, actions: sliceActions } = createSlice({
|
|
646
|
-
name: authStoreName,
|
|
647
|
-
initialState,
|
|
648
|
-
reducers: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ resetState: (state) => (Object.assign(Object.assign({}, state), reinitializeState)), setState: (state, { payload }) => (Object.assign(Object.assign({}, state), payload)), setUser: typeReducer('user') }, reducers$f), reducers$6), reducers$e), reducers$d), reducers$c), reducers$b), reducers$5), reducers$9), reducers$a), reducers$8), reducers$7), reducers$4), reducers$3), reducers$2), reducers$1), reducers),
|
|
649
|
-
});
|
|
650
|
-
const actions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sliceActions), actions$g), actions$7), actions$f), actions$e), actions$d), actions$c), actions$6), actions$a), actions$b), actions$9), actions$8), actions$5), actions$4), actions$3), actions$2), actions$1);
|
|
651
|
-
|
|
652
|
-
var SSOStateKeys;
|
|
653
|
-
(function (SSOStateKeys) {
|
|
654
|
-
SSOStateKeys["LOAD_SSO_CONFIGURATIONS"] = "LOAD_SSO_CONFIGURATIONS";
|
|
655
|
-
SSOStateKeys["SAVE_SSO_CONFIGURATION"] = "SAVE_SSO_CONFIGURATION";
|
|
656
|
-
SSOStateKeys["UPDATE_SSO_CONFIGURATION"] = "UPDATE_SSO_CONFIGURATION";
|
|
657
|
-
SSOStateKeys["SAVE_SSO_CONFIGURATION_BY_METADATA"] = "SAVE_SSO_CONFIGURATION_BY_METADATA";
|
|
658
|
-
SSOStateKeys["UPDATE_SSO_CONFIGURATION_BY_METADATA"] = "UPDATE_SSO_CONFIGURATION";
|
|
659
|
-
SSOStateKeys["DELETE_SSO_CONFIGURATION"] = "DELETE_SSO_CONFIGURATION";
|
|
660
|
-
SSOStateKeys["SAVE_SSO_DOMAIN"] = "SAVE_SSO_DOMAIN";
|
|
661
|
-
SSOStateKeys["DELETE_SSO_DOMAIN"] = "DELETE_SSO_DOMAIN";
|
|
662
|
-
SSOStateKeys["VALIDATE_SSO_DOMAIN"] = "VALIDATE_SSO_DOMAIN";
|
|
663
|
-
SSOStateKeys["UPDATE_SSO_DEFAULT_ROLES"] = "UPDATE_SSO_DEFAULT_ROLES";
|
|
664
|
-
SSOStateKeys["DELETE_SSO_GROUPS"] = "DELETE_SSO_GROUPS";
|
|
665
|
-
SSOStateKeys["SAVE_SSO_GROUPS"] = "SAVE_SSO_GROUPS";
|
|
666
|
-
SSOStateKeys["GET_SSO_AUTHORIZATION_ROLES"] = "GET_SSO_AUTHORIZATION_ROLES";
|
|
667
|
-
})(SSOStateKeys || (SSOStateKeys = {}));
|
|
668
|
-
var SamlVendors;
|
|
669
|
-
(function (SamlVendors) {
|
|
670
|
-
SamlVendors["Saml"] = "saml";
|
|
671
|
-
SamlVendors["Okta"] = "okta";
|
|
672
|
-
SamlVendors["Azure"] = "azure";
|
|
673
|
-
SamlVendors["Google"] = "google";
|
|
674
|
-
SamlVendors["Oidc"] = "oidc";
|
|
675
|
-
})(SamlVendors || (SamlVendors = {}));
|
|
676
|
-
|
|
677
|
-
function omitProps(props, keys) {
|
|
678
|
-
const newProps = Object.assign({}, props);
|
|
679
|
-
keys.forEach((key) => {
|
|
680
|
-
delete newProps[key];
|
|
681
|
-
});
|
|
682
|
-
return newProps;
|
|
683
|
-
}
|
|
684
|
-
function generateCodeChallenge(codeVerifier) {
|
|
685
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
686
|
-
const digest = yield crypto.subtle.digest('SHA-256', new TextEncoder().encode(codeVerifier));
|
|
687
|
-
// @ts-ignore
|
|
688
|
-
return btoa(String.fromCharCode(...new Uint8Array(digest)))
|
|
689
|
-
.replace(/=/g, '')
|
|
690
|
-
.replace(/\+/g, '-')
|
|
691
|
-
.replace(/\//g, '_');
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
function createRandomString(length = 16) {
|
|
695
|
-
let text = '';
|
|
696
|
-
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
697
|
-
for (let i = 0; i < length; i++) {
|
|
698
|
-
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
699
|
-
}
|
|
700
|
-
return text;
|
|
701
|
-
}
|
|
702
|
-
const readFileAsText = (file) => new Promise((resolve, reject) => {
|
|
703
|
-
const reader = new FileReader();
|
|
704
|
-
reader.readAsText(file);
|
|
705
|
-
reader.onload = () => resolve(reader.result);
|
|
706
|
-
reader.onerror = reject;
|
|
707
|
-
});
|
|
708
|
-
|
|
709
|
-
const apiTokensDataDemo = {
|
|
710
|
-
clientId: 'CLIENT_ID_16806d3d-8fc3-4450-be97-abdaf66b723e',
|
|
711
|
-
secret: 'SECRET_16806d3d-8fc3-4450-be97-abdaf66b723e',
|
|
712
|
-
createdAt: 'createdAt',
|
|
713
|
-
description: 'Demo API Token (preview only)',
|
|
714
|
-
};
|
|
715
|
-
const apiTokensDataTenantDemo = Object.assign(Object.assign({}, apiTokensDataDemo), { roleIds: [], tenantId: 'my-tenant-id', createdByUserId: 'createdByUserId' });
|
|
716
|
-
const roleDemo = [
|
|
717
|
-
{
|
|
718
|
-
id: 'roleId',
|
|
719
|
-
key: 'admin',
|
|
720
|
-
isDefault: false,
|
|
721
|
-
name: 'Admin',
|
|
722
|
-
description: null,
|
|
723
|
-
permissions: ['adminPermissionId'],
|
|
724
|
-
tenantId: 'tenantId',
|
|
725
|
-
vendorId: 'vendorId',
|
|
726
|
-
createdAt: new Date(),
|
|
727
|
-
updatedAt: new Date(),
|
|
728
|
-
},
|
|
729
|
-
];
|
|
730
|
-
const rolePermissionDemo = [
|
|
731
|
-
{
|
|
732
|
-
id: 'adminPermissionId',
|
|
733
|
-
key: 'fe.*',
|
|
734
|
-
name: 'General Admin',
|
|
735
|
-
description: undefined,
|
|
736
|
-
categoryId: 'category',
|
|
737
|
-
fePermission: true,
|
|
738
|
-
createdAt: new Date(),
|
|
739
|
-
updatedAt: new Date(),
|
|
740
|
-
},
|
|
741
|
-
];
|
|
742
|
-
const userProfileDemo = {
|
|
743
|
-
id: 'testId',
|
|
744
|
-
name: 'Demo User Name',
|
|
745
|
-
email: 'demo-user@frontegg.com',
|
|
746
|
-
mfaEnrolled: true,
|
|
747
|
-
profileImage: undefined,
|
|
748
|
-
profilePictureUrl: 'https://www.gravatar.com/avatar/42b2ad2bad6fc9b9db5086dfcf8072ac?d=https://ui-avatars.com/api/fe/128/random?t=1617261890875?t=1617261917434',
|
|
749
|
-
roles: roleDemo,
|
|
750
|
-
permissions: rolePermissionDemo,
|
|
751
|
-
tenantId: 'my-tenant-id',
|
|
752
|
-
tenantIds: ['my-tenant-id'],
|
|
753
|
-
activatedForTenant: true,
|
|
754
|
-
metadata: JSON.stringify({
|
|
755
|
-
phoneNumber: '+972-54123456',
|
|
756
|
-
jobTitle: 'Developer',
|
|
757
|
-
address: {
|
|
758
|
-
city: "Tel Aviv",
|
|
759
|
-
country: "Israel"
|
|
760
|
-
}
|
|
761
|
-
}),
|
|
762
|
-
roleIds: undefined,
|
|
763
|
-
verified: undefined,
|
|
764
|
-
};
|
|
765
|
-
const userDemo = Object.assign(Object.assign({}, userProfileDemo), { accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1MTY5YmY0Zi02YmI5LTQ5NGMtOGNkZS05MDc4NDQ0NWY4MDciLCJuYW1lIjoiRHVtbXkgVXNlciIsImVtYWlsIjoiZHVtbXlAZnJvbnRlZ2cuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsIm1ldGFkYXRhIjp7fSwicm9sZXMiOlsiYWRtaW4iXSwicGVybWlzc2lvbnMiOlsiZmUuKiJdLCJ0ZW5hbnRJZCI6Im15LXRlbmFudC1pZCIsInRlbmFudElkcyI6WyJteS10ZW5hbnQtaWQiXSwicHJvZmlsZVBpY3R1cmVVcmwiOiJodHRwczovL3d3dy5ncmF2YXRhci5jb20vYXZhdGFyLzQyYjJhZDJiYWQ2ZmM5YjlkYjUwODZkZmNmODA3MmFjP2Q9aHR0cHM6Ly91aS1hdmF0YXJzLmNvbS9hcGkvZmUvMTI4L3JhbmRvbT90PTE2MTcyNjE4OTA4NzU_dD0xNjE3MjYxOTE3NDM0IiwidHlwZSI6InVzZXJUb2tlbiIsImlhdCI6MTYxNzkwNjMyNCwiZXhwIjoxNjE3OTkyNzI0LCJpc3MiOiJmcm9udGVnZyJ9.paaXLkpWEWbQmUtoK2P8IwXCxK4WJp7XhXonvzF8g1I', expiresIn: 86400, mfaRequired: false, refreshToken: 'refresh-token-dummy-de39dc9c-9d22-4852-b7f5-c3c0aa613b58', type: 'userToken', iat: 1617906324, exp: 1617992724, iss: 'frontegg', email_verified: true });
|
|
766
|
-
const profileStateDemo = {
|
|
767
|
-
loading: false,
|
|
768
|
-
error: undefined,
|
|
769
|
-
saving: true,
|
|
770
|
-
profile: userProfileDemo,
|
|
771
|
-
};
|
|
772
|
-
const policyDemo = {
|
|
773
|
-
id: 'id',
|
|
774
|
-
enforceMFAType: 'DontForce',
|
|
775
|
-
createdAt: new Date(),
|
|
776
|
-
updatedAt: new Date(),
|
|
777
|
-
allowOverrideEnforcePasswordHistory: true,
|
|
778
|
-
allowOverridePasswordComplexity: false,
|
|
779
|
-
allowOverridePasswordExpiration: false,
|
|
780
|
-
allowSignups: true,
|
|
781
|
-
apiTokensEnabled: true,
|
|
782
|
-
cookieSameSite: 'cookieSameSite',
|
|
783
|
-
defaultRefreshTokenExpiration: 0,
|
|
784
|
-
defaultTokenExpiration: 1,
|
|
785
|
-
publicKey: 'publicKey',
|
|
786
|
-
};
|
|
787
|
-
const publicSecurityPolicy = {
|
|
788
|
-
allowSignups: true,
|
|
789
|
-
allowNotVerifiedUsersLogin: false,
|
|
790
|
-
apiTokensEnabled: true,
|
|
791
|
-
forcePermissions: false,
|
|
792
|
-
authStrategy: AuthStrategyEnum.EmailAndPassword,
|
|
793
|
-
};
|
|
794
|
-
const policyMfaDemo = {
|
|
795
|
-
id: 'id',
|
|
796
|
-
enforceMFAType: 'DontForce',
|
|
797
|
-
createdAt: new Date(),
|
|
798
|
-
updatedAt: new Date(),
|
|
799
|
-
};
|
|
800
|
-
const policyLockoutDemo = {
|
|
801
|
-
id: 'id',
|
|
802
|
-
enabled: true,
|
|
803
|
-
maxAttempts: 1,
|
|
804
|
-
createdAt: new Date(),
|
|
805
|
-
updatedAt: new Date(),
|
|
806
|
-
};
|
|
807
|
-
const policyPasswordHistoryDemo = {
|
|
808
|
-
id: 'id',
|
|
809
|
-
enabled: true,
|
|
810
|
-
historySize: 1,
|
|
811
|
-
createdAt: new Date(),
|
|
812
|
-
updatedAt: new Date(),
|
|
813
|
-
};
|
|
814
|
-
const samlConfigurationDemo = {
|
|
815
|
-
enabled: true,
|
|
816
|
-
domain: 'domain',
|
|
817
|
-
validated: true,
|
|
818
|
-
generatedVerification: 'generatedVerification',
|
|
819
|
-
ssoEndpoint: 'ssoEndpoint',
|
|
820
|
-
publicCertificate: 'publicCertificate',
|
|
821
|
-
signRequest: true,
|
|
822
|
-
createdAt: new Date(),
|
|
823
|
-
updatedAt: new Date(),
|
|
824
|
-
acsUrl: undefined,
|
|
825
|
-
spEntityId: undefined,
|
|
826
|
-
oidcClientId: undefined,
|
|
827
|
-
oidcSecret: undefined,
|
|
828
|
-
type: undefined,
|
|
829
|
-
};
|
|
830
|
-
const samlMetadataDemo = {
|
|
831
|
-
id: 'id',
|
|
832
|
-
createdAt: 'createdAt',
|
|
833
|
-
updatedAt: 'updatedAt',
|
|
834
|
-
properties: [],
|
|
835
|
-
vendorId: 'vendorId',
|
|
836
|
-
entityName: 'saml',
|
|
837
|
-
isActive: true,
|
|
838
|
-
configuration: {
|
|
839
|
-
acsUrl: 'acsUrl',
|
|
840
|
-
spEntityId: 'spEntityId',
|
|
841
|
-
},
|
|
842
|
-
};
|
|
843
|
-
const rolesDemo = [
|
|
844
|
-
{
|
|
845
|
-
id: 'id',
|
|
846
|
-
description: 'description',
|
|
847
|
-
key: 'key',
|
|
848
|
-
name: 'name',
|
|
849
|
-
permissions: [],
|
|
850
|
-
permissionLevel: 1,
|
|
851
|
-
},
|
|
852
|
-
];
|
|
853
|
-
const ssoStateDemo = {
|
|
854
|
-
firstLoad: false,
|
|
855
|
-
loading: false,
|
|
856
|
-
error: undefined,
|
|
857
|
-
saving: false,
|
|
858
|
-
samlConfiguration: samlConfigurationDemo,
|
|
859
|
-
roles: rolesDemo,
|
|
860
|
-
authorizationRoles: [],
|
|
861
|
-
errors: {},
|
|
862
|
-
loaders: {},
|
|
863
|
-
ssoConfigurations: [],
|
|
864
|
-
};
|
|
865
|
-
const permissionsDemo = [
|
|
866
|
-
{
|
|
867
|
-
description: 'string',
|
|
868
|
-
fePermission: true,
|
|
869
|
-
id: 'id',
|
|
870
|
-
key: 'key',
|
|
871
|
-
name: 'name',
|
|
872
|
-
roleIds: [],
|
|
873
|
-
createdAt: new Date(),
|
|
874
|
-
updatedAt: new Date(),
|
|
875
|
-
categoryId: 'categoryId',
|
|
876
|
-
},
|
|
877
|
-
];
|
|
878
|
-
const userTeamDemo2 = {
|
|
879
|
-
id: 'id2',
|
|
880
|
-
email: 'demo-user2@frontegg.com',
|
|
881
|
-
name: 'Demo User Name2',
|
|
882
|
-
phone: undefined,
|
|
883
|
-
profileImage: undefined,
|
|
884
|
-
profileImageUrl: undefined,
|
|
885
|
-
tenantId: 'tenantId',
|
|
886
|
-
vendorId: 'vendorId',
|
|
887
|
-
roleIds: [],
|
|
888
|
-
activatedForTenant: true,
|
|
889
|
-
verified: false,
|
|
890
|
-
createdAt: new Date().toISOString(),
|
|
891
|
-
customData: undefined,
|
|
892
|
-
lastLogin: undefined,
|
|
893
|
-
mfaEnabled: undefined,
|
|
894
|
-
roles: [],
|
|
895
|
-
}; // TODO add verified to ITeamUser
|
|
896
|
-
const userTeamDemo = {
|
|
897
|
-
id: 'id',
|
|
898
|
-
email: 'demo-user@frontegg.com',
|
|
899
|
-
name: 'Demo User Name',
|
|
900
|
-
phone: undefined,
|
|
901
|
-
profileImage: undefined,
|
|
902
|
-
profileImageUrl: undefined,
|
|
903
|
-
tenantId: 'tenantId',
|
|
904
|
-
vendorId: 'vendorId',
|
|
905
|
-
roleIds: [],
|
|
906
|
-
activatedForTenant: true,
|
|
907
|
-
createdAt: new Date(2022, 4, 1).toISOString(),
|
|
908
|
-
verified: true,
|
|
909
|
-
customData: undefined,
|
|
910
|
-
lastLogin: new Date(2022, 5, 25).toISOString(),
|
|
911
|
-
mfaEnabled: undefined,
|
|
912
|
-
roles: [],
|
|
913
|
-
};
|
|
914
|
-
const userSubTenantDemo = {
|
|
915
|
-
metadata: '',
|
|
916
|
-
mfaEnrolled: false,
|
|
917
|
-
permissions: [],
|
|
918
|
-
provider: '',
|
|
919
|
-
sub: '',
|
|
920
|
-
tenantIds: [],
|
|
921
|
-
tenants: [],
|
|
922
|
-
verified: false,
|
|
923
|
-
id: 'id',
|
|
924
|
-
email: 'email',
|
|
925
|
-
name: 'name',
|
|
926
|
-
tenantId: 'tenantId',
|
|
927
|
-
activatedForTenant: true,
|
|
928
|
-
createdAt: new Date(),
|
|
929
|
-
lastLogin: new Date(),
|
|
930
|
-
roles: [],
|
|
931
|
-
};
|
|
932
|
-
const usersDemo = [userTeamDemo, userTeamDemo2];
|
|
933
|
-
const allUsersDemo = [userSubTenantDemo];
|
|
934
|
-
const tenantsDemo = [
|
|
935
|
-
{
|
|
936
|
-
id: 'my-tenant-id',
|
|
937
|
-
isReseller: false,
|
|
938
|
-
name: 'Frontegg demo',
|
|
939
|
-
deletedAt: null,
|
|
940
|
-
metadata: undefined,
|
|
941
|
-
tenantId: 'my-tenant-id',
|
|
942
|
-
vendorId: 'vendorId',
|
|
943
|
-
createdAt: new Date(),
|
|
944
|
-
updatedAt: new Date(),
|
|
945
|
-
address: undefined,
|
|
946
|
-
timezone: undefined,
|
|
947
|
-
dateFormat: undefined,
|
|
948
|
-
timeFormat: undefined,
|
|
949
|
-
currency: undefined,
|
|
950
|
-
logo: undefined,
|
|
951
|
-
},
|
|
952
|
-
];
|
|
953
|
-
|
|
954
|
-
var UserVeirifedOriginTypes;
|
|
955
|
-
(function (UserVeirifedOriginTypes) {
|
|
956
|
-
UserVeirifedOriginTypes["SOCIAL_LOGIN"] = "SOCIAL_LOGIN";
|
|
957
|
-
UserVeirifedOriginTypes["PASSWORDLESS"] = "PASSWORDLESS";
|
|
958
|
-
UserVeirifedOriginTypes["ACTIVATION_LINK"] = "ACTIVATION_LINK";
|
|
959
|
-
})(UserVeirifedOriginTypes || (UserVeirifedOriginTypes = {}));
|
|
960
|
-
var AuthenticationTypes;
|
|
961
|
-
(function (AuthenticationTypes) {
|
|
962
|
-
AuthenticationTypes["SOCIAL_LOGIN"] = "SOCIAL_LOGIN";
|
|
963
|
-
AuthenticationTypes["PASSWORD"] = "PASSWORD";
|
|
964
|
-
})(AuthenticationTypes || (AuthenticationTypes = {}));
|
|
965
|
-
|
|
966
|
-
function* loadAllowSignUps() {
|
|
967
|
-
yield put(actions.setSignUpState({ loading: true }));
|
|
968
|
-
try {
|
|
969
|
-
const policy = yield call(api.auth.getVendorConfig);
|
|
970
|
-
const { allowSignups: allowSignUps, allowNotVerifiedUsersLogin } = policy;
|
|
971
|
-
yield put(actions.setSignUpState({ loading: false, allowSignUps, allowNotVerifiedUsersLogin, firstLoad: false }));
|
|
972
|
-
yield put(actions.setSecurityPolicyPublicState({ policy, loading: false }));
|
|
973
|
-
}
|
|
974
|
-
catch (e) {
|
|
975
|
-
yield put(actions.setSignUpState({ loading: false, error: e.message, firstLoad: false }));
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
function* signUpUser(_a) {
|
|
979
|
-
var _b;
|
|
980
|
-
var _c = _a.payload, { events, url } = _c, payload = __rest(_c, ["events", "url"]);
|
|
981
|
-
yield put(actions.setSignUpState({ loading: true }));
|
|
982
|
-
try {
|
|
983
|
-
const { routes, onRedirectTo } = yield select((state) => state.auth);
|
|
984
|
-
const { shouldActivate, user, tenantId, userId } = yield call(api.auth.signUpUser, payload);
|
|
985
|
-
if (!payload.invitationToken) {
|
|
986
|
-
const { email, name, companyName } = payload;
|
|
987
|
-
(_b = events === null || events === void 0 ? void 0 : events.signUpComplete) === null || _b === void 0 ? void 0 : _b.call(events, {
|
|
988
|
-
email,
|
|
989
|
-
name,
|
|
990
|
-
companyName,
|
|
991
|
-
url,
|
|
992
|
-
authenticationType: AuthenticationTypes.PASSWORD,
|
|
993
|
-
id: userId,
|
|
994
|
-
tenantId,
|
|
995
|
-
createdAt: new Date(),
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
ContextHolder.setAccessToken(user === null || user === void 0 ? void 0 : user.accessToken);
|
|
999
|
-
ContextHolder.setUser(user);
|
|
1000
|
-
if (!shouldActivate && (user === null || user === void 0 ? void 0 : user.mfaRequired) && (user === null || user === void 0 ? void 0 : user.mfaToken)) {
|
|
1001
|
-
let step = LoginStep.loginWithTwoFactor;
|
|
1002
|
-
if (user.hasOwnProperty('mfaEnrolled') && !user.mfaEnrolled) {
|
|
1003
|
-
yield put(actions.setMfaState({
|
|
1004
|
-
step: MFAStep.verify,
|
|
1005
|
-
qrCode: user.qrCode,
|
|
1006
|
-
recoveryCode: user.recoveryCode,
|
|
1007
|
-
mfaToken: user.mfaToken,
|
|
1008
|
-
loading: false,
|
|
1009
|
-
}));
|
|
1010
|
-
step = LoginStep.forceTwoFactor;
|
|
1011
|
-
}
|
|
1012
|
-
yield put(actions.setLoginState({ step }));
|
|
1013
|
-
onRedirectTo(routes.loginUrl);
|
|
1014
|
-
}
|
|
1015
|
-
else {
|
|
1016
|
-
yield put(actions.setSignUpState({ loading: false, shouldActivate, stage: SignUpStage.SignUpSuccess }));
|
|
1017
|
-
yield put(actions.setState({
|
|
1018
|
-
user,
|
|
1019
|
-
isAuthenticated: !!(user === null || user === void 0 ? void 0 : user.accessToken),
|
|
1020
|
-
}));
|
|
1021
|
-
if (!shouldActivate) {
|
|
1022
|
-
yield put(actions.loadTenants());
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
catch (e) {
|
|
1027
|
-
ContextHolder.setAccessToken(null);
|
|
1028
|
-
ContextHolder.setUser(null);
|
|
1029
|
-
yield put(actions.setSignUpState({ loading: false, error: e.message }));
|
|
1030
|
-
}
|
|
1031
|
-
yield put(actions.setSignUpState({ loading: false }));
|
|
1032
|
-
}
|
|
1033
|
-
function* resetSignUpStateSoft() {
|
|
1034
|
-
const { allowSignUps, allowNotVerifiedUsersLogin } = yield select((state) => state.auth.signUpState);
|
|
1035
|
-
yield put(actions.resetSignUpState());
|
|
1036
|
-
yield put(actions.setSignUpState({ allowSignUps, allowNotVerifiedUsersLogin }));
|
|
1037
|
-
}
|
|
1038
|
-
function* signUpSaga() {
|
|
1039
|
-
yield takeLeading(actions.signUpUser, signUpUser);
|
|
1040
|
-
yield takeLeading(actions.resetSignUpStateSoft, resetSignUpStateSoft);
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
const authStrategyLoginStepMap = {
|
|
1044
|
-
[AuthStrategyEnum.Code]: LoginStep.loginWithOtc,
|
|
1045
|
-
[AuthStrategyEnum.EmailAndPassword]: LoginStep.loginWithPassword,
|
|
1046
|
-
[AuthStrategyEnum.MagicLink]: LoginStep.magicLinkPreLoginSuccess,
|
|
1047
|
-
[AuthStrategyEnum.SmsCode]: LoginStep.loginWithSmsOtc,
|
|
1048
|
-
};
|
|
1049
|
-
function* afterAuthNavigation() {
|
|
1050
|
-
var _a;
|
|
1051
|
-
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
1052
|
-
const { routes, includeQueryParam } = yield select((state) => state.auth);
|
|
1053
|
-
const { loginUrl, logoutUrl, socialLoginCallbackUrl, activateUrl } = routes;
|
|
1054
|
-
let { authenticatedUrl } = routes;
|
|
1055
|
-
const afterAuthRedirect = window.localStorage.getItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL);
|
|
1056
|
-
if (afterAuthRedirect && ![loginUrl, logoutUrl, socialLoginCallbackUrl, activateUrl].includes(afterAuthRedirect)) {
|
|
1057
|
-
authenticatedUrl = afterAuthRedirect;
|
|
1058
|
-
}
|
|
1059
|
-
window.localStorage.removeItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL);
|
|
1060
|
-
yield delay$1(200);
|
|
1061
|
-
put(actions.resetLoginState());
|
|
1062
|
-
const url = new URL(window === null || window === void 0 ? void 0 : window.location.href);
|
|
1063
|
-
let redirectUrl = authenticatedUrl;
|
|
1064
|
-
if (url.searchParams.get('redirectUrl')) {
|
|
1065
|
-
redirectUrl = (_a = url.searchParams.get('redirectUrl')) !== null && _a !== void 0 ? _a : authenticatedUrl;
|
|
1066
|
-
}
|
|
1067
|
-
else if (includeQueryParam) {
|
|
1068
|
-
redirectUrl += window.location.search;
|
|
1069
|
-
}
|
|
1070
|
-
onRedirectTo(redirectUrl, { refresh: redirectUrl.startsWith('http') });
|
|
1071
|
-
}
|
|
1072
|
-
function* refreshMetadata() {
|
|
1073
|
-
var _a;
|
|
1074
|
-
let ssoACS;
|
|
1075
|
-
try {
|
|
1076
|
-
const metadata = yield call(api.metadata.getSamlMetadata);
|
|
1077
|
-
ssoACS = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.configuration) === null || _a === void 0 ? void 0 : _a.acsUrl;
|
|
1078
|
-
}
|
|
1079
|
-
catch (e) {
|
|
1080
|
-
console.error(e);
|
|
1081
|
-
}
|
|
1082
|
-
yield put(actions.setState({ ssoACS }));
|
|
1083
|
-
}
|
|
1084
|
-
function* loadSSOPublicConfigurationFunction() {
|
|
1085
|
-
try {
|
|
1086
|
-
const { isActive } = yield call(api.auth.getSSOPublicConfiguration);
|
|
1087
|
-
yield put(actions.setState({ isSSOAuth: isActive }));
|
|
1088
|
-
}
|
|
1089
|
-
catch (e) {
|
|
1090
|
-
console.error(e);
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
const isMfaRequired = (user) => {
|
|
1094
|
-
if (user.mfaRequired && user.mfaToken) {
|
|
1095
|
-
ContextHolder.setAccessToken(null);
|
|
1096
|
-
ContextHolder.setUser(null);
|
|
1097
|
-
return true;
|
|
1098
|
-
}
|
|
1099
|
-
else {
|
|
1100
|
-
ContextHolder.setAccessToken(user.accessToken);
|
|
1101
|
-
ContextHolder.setUser(user);
|
|
1102
|
-
return false;
|
|
1103
|
-
}
|
|
1104
|
-
};
|
|
1105
|
-
function* getMfaRequiredState(user) {
|
|
1106
|
-
let setMfaState = {};
|
|
1107
|
-
let step = LoginStep.loginWithTwoFactor;
|
|
1108
|
-
const { loginState } = yield select((state) => state.auth);
|
|
1109
|
-
const { isAllowedToRemember, mfaDeviceExpiration } = yield call(api.auth.checkIfAllowToRememberMfaDevice, user.mfaToken);
|
|
1110
|
-
if (user.hasOwnProperty('mfaEnrolled') && !user.mfaEnrolled) {
|
|
1111
|
-
setMfaState = {
|
|
1112
|
-
mfaState: {
|
|
1113
|
-
step: MFAStep.verify,
|
|
1114
|
-
qrCode: user.qrCode,
|
|
1115
|
-
recoveryCode: user.recoveryCode,
|
|
1116
|
-
loading: false,
|
|
1117
|
-
mfaToken: user.mfaToken,
|
|
1118
|
-
},
|
|
1119
|
-
};
|
|
1120
|
-
step = LoginStep.forceTwoFactor;
|
|
1121
|
-
}
|
|
1122
|
-
return Object.assign(Object.assign({ user: undefined, isAuthenticated: false }, setMfaState), { loginState: Object.assign(Object.assign({}, loginState), { mfaToken: user.mfaToken, mfaRequired: user.mfaRequired, loading: false, error: undefined, step, tenantsLoading: true, tenants: [], allowRememberMfaDevice: isAllowedToRemember, mfaDeviceExpiration }) });
|
|
1123
|
-
}
|
|
1124
|
-
function* refreshToken() {
|
|
1125
|
-
var _a;
|
|
1126
|
-
try {
|
|
1127
|
-
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
1128
|
-
const { routes, loginState } = yield select((state) => state.auth);
|
|
1129
|
-
const { user, tenants } = yield call(api.auth.refreshTokenV2);
|
|
1130
|
-
if (isMfaRequired(user)) {
|
|
1131
|
-
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
1132
|
-
yield put(actions.setState(mfaRequiredState));
|
|
1133
|
-
onRedirectTo(routes.loginUrl, { preserveQueryParams: true });
|
|
1134
|
-
}
|
|
1135
|
-
else {
|
|
1136
|
-
if (user.email) {
|
|
1137
|
-
localStorage.setItem('email', user.email);
|
|
1138
|
-
}
|
|
1139
|
-
const quickLoginToRegister = (_a = localStorage.getItem('register-quick-login')) !== null && _a !== void 0 ? _a : loginState.quickLoginToRegister;
|
|
1140
|
-
const shouldNavigateToRegisterQuicKLogin = quickLoginToRegister && localStorage.getItem(`${user.email}-${quickLoginToRegister}`) !== 'true';
|
|
1141
|
-
yield put(actions.setTenantsState({ tenants, loading: false }));
|
|
1142
|
-
yield put(actions.setState({
|
|
1143
|
-
user,
|
|
1144
|
-
isAuthenticated: true,
|
|
1145
|
-
loginState: Object.assign(Object.assign({}, loginState), { quickLoginToRegister, flow: shouldNavigateToRegisterQuicKLogin ? LoginFlow.RegisterQuickLogin : LoginFlow.Login })
|
|
1146
|
-
}));
|
|
1147
|
-
if (shouldNavigateToRegisterQuicKLogin) {
|
|
1148
|
-
onRedirectTo(routes.loginUrl);
|
|
1149
|
-
}
|
|
1150
|
-
else if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signUpUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl]
|
|
1151
|
-
.some(url => url && window.location.pathname.endsWith(url))) {
|
|
1152
|
-
if (loginState.isNewUser && routes.signUpSuccessUrl && routes.socialLoginCallbackUrl === window.location.pathname) {
|
|
1153
|
-
onRedirectTo(routes.signUpSuccessUrl, { refresh: routes.signUpSuccessUrl.startsWith('http') });
|
|
1154
|
-
}
|
|
1155
|
-
else {
|
|
1156
|
-
yield afterAuthNavigation();
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
catch (e) {
|
|
1162
|
-
ContextHolder.setAccessToken(null);
|
|
1163
|
-
ContextHolder.setUser(null);
|
|
1164
|
-
yield put(actions.setState({ user: undefined, isAuthenticated: false }));
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
function* requestAuthorize({ payload: firstTime }) {
|
|
1168
|
-
const calls = [];
|
|
1169
|
-
if (firstTime) {
|
|
1170
|
-
yield put(actions.setState({ isLoading: true }));
|
|
1171
|
-
yield put(actions.loadSocialLoginsConfigurationV2());
|
|
1172
|
-
calls.push(call(loadAllowSignUps));
|
|
1173
|
-
calls.push(call(loadSSOPublicConfigurationFunction));
|
|
1174
|
-
calls.push(call(loadVendorPublicInfo));
|
|
1175
|
-
calls.push(call(refreshMetadata));
|
|
1176
|
-
}
|
|
1177
|
-
calls.push(call(refreshToken));
|
|
1178
|
-
yield all(calls);
|
|
1179
|
-
yield put(actions.setState({ isLoading: false }));
|
|
1180
|
-
}
|
|
1181
|
-
function* refreshTokenSSR(accessToken) {
|
|
1182
|
-
if (!accessToken) {
|
|
1183
|
-
ContextHolder.setAccessToken(null);
|
|
1184
|
-
ContextHolder.setUser(null);
|
|
1185
|
-
yield put(actions.setState({ user: undefined, isAuthenticated: false }));
|
|
1186
|
-
return;
|
|
1187
|
-
}
|
|
1188
|
-
try {
|
|
1189
|
-
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
1190
|
-
const { routes } = yield select((state) => state.auth);
|
|
1191
|
-
const { user, tenants } = yield call(api.auth.generateLoginResponseV2, { accessToken });
|
|
1192
|
-
if (isMfaRequired(user)) {
|
|
1193
|
-
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
1194
|
-
yield put(actions.setState(mfaRequiredState));
|
|
1195
|
-
onRedirectTo(routes.loginUrl, { preserveQueryParams: true });
|
|
1196
|
-
}
|
|
1197
|
-
else {
|
|
1198
|
-
yield put(actions.setTenantsState({ tenants, loading: false }));
|
|
1199
|
-
yield put(actions.setState({ user, isAuthenticated: true }));
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
catch (e) {
|
|
1203
|
-
ContextHolder.setAccessToken(null);
|
|
1204
|
-
ContextHolder.setUser(null);
|
|
1205
|
-
yield put(actions.setState({ user: undefined, isAuthenticated: false }));
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
function* requestAuthorizeSSR({ payload: accessToken }) {
|
|
1209
|
-
const calls = [];
|
|
1210
|
-
yield put(actions.setState({ isLoading: true }));
|
|
1211
|
-
yield put(actions.loadSocialLoginsConfigurationV2());
|
|
1212
|
-
calls.push(call(loadAllowSignUps));
|
|
1213
|
-
calls.push(call(loadSSOPublicConfigurationFunction));
|
|
1214
|
-
calls.push(call(loadVendorPublicInfo));
|
|
1215
|
-
calls.push(call(refreshMetadata));
|
|
1216
|
-
calls.push(call(refreshTokenSSR, accessToken));
|
|
1217
|
-
yield all(calls);
|
|
1218
|
-
yield put(actions.setState({ isLoading: false }));
|
|
1219
|
-
}
|
|
1220
|
-
function* requestHostedLoginAuthorize() {
|
|
1221
|
-
const { routes, context, onRedirectTo } = yield select((state) => ({
|
|
1222
|
-
routes: state.auth.routes,
|
|
1223
|
-
onRedirectTo: state.auth.onRedirectTo,
|
|
1224
|
-
context: state.root.context,
|
|
1225
|
-
}));
|
|
1226
|
-
// Generate the relevant params for the redirect
|
|
1227
|
-
const nonce = createRandomString();
|
|
1228
|
-
const code_verifier = createRandomString();
|
|
1229
|
-
const code_challenge = yield call(generateCodeChallenge, code_verifier);
|
|
1230
|
-
// We are saving the verifier in session storage to be able to validate the response
|
|
1231
|
-
localStorage.setItem(HOSTED_LOGIN_VERIFIER_KEY, code_verifier);
|
|
1232
|
-
const redirectUrl = `${window.location.origin}${routes.hostedLoginRedirectUrl}`;
|
|
1233
|
-
const baseUrl = fetch.getBaseUrl(context, '/oauth/authorize');
|
|
1234
|
-
// Hard coded for now
|
|
1235
|
-
const oauthUrl = `${baseUrl}/oauth/authorize`;
|
|
1236
|
-
const params = {
|
|
1237
|
-
response_type: 'code',
|
|
1238
|
-
client_id: context.clientId || 'INVALID-CLIENT-ID',
|
|
1239
|
-
scope: 'openid email profile',
|
|
1240
|
-
redirect_uri: redirectUrl,
|
|
1241
|
-
code_challenge: code_challenge,
|
|
1242
|
-
code_challenge_method: 'S256',
|
|
1243
|
-
nonce,
|
|
1244
|
-
};
|
|
1245
|
-
const searchParams = new URLSearchParams(params);
|
|
1246
|
-
const url = `${oauthUrl}?${searchParams.toString()}`;
|
|
1247
|
-
onRedirectTo(url, { refresh: true });
|
|
1248
|
-
}
|
|
1249
|
-
function* handleHostedLoginCallback({ payload }) {
|
|
1250
|
-
// Hard coded for now
|
|
1251
|
-
const code_verifier = localStorage.getItem(HOSTED_LOGIN_VERIFIER_KEY) || 'INVALID-CODE-VERIFIER';
|
|
1252
|
-
const routes = yield select((state) => state.auth.routes);
|
|
1253
|
-
const redirectUrl = `${window.location.origin}${routes.hostedLoginRedirectUrl}`;
|
|
1254
|
-
const body = {
|
|
1255
|
-
code: payload.code,
|
|
1256
|
-
redirect_uri: redirectUrl,
|
|
1257
|
-
code_verifier,
|
|
1258
|
-
grant_type: 'authorization_code',
|
|
1259
|
-
};
|
|
1260
|
-
const user = yield call(api.auth.exchangeOAuthTokens, body);
|
|
1261
|
-
// TODO: Validate nonce and aud
|
|
1262
|
-
yield put(actions.setState({ user, isAuthenticated: true }));
|
|
1263
|
-
yield put(actions.loadTenants());
|
|
1264
|
-
yield afterAuthNavigation();
|
|
1265
|
-
}
|
|
1266
|
-
function* passwordlessPreLogin(_a) {
|
|
1267
|
-
var _b = _a.payload, { callback } = _b, payload = __rest(_b, ["callback"]);
|
|
1268
|
-
try {
|
|
1269
|
-
const { onRedirectTo, routes } = yield select(({ auth: { onRedirectTo, routes } }) => ({ onRedirectTo, routes }));
|
|
1270
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1271
|
-
const preloginRes = yield call(api.auth.passwordlessPreLogin, payload);
|
|
1272
|
-
const step = authStrategyLoginStepMap[payload.type];
|
|
1273
|
-
if (step === LoginStep.loginWithSmsOtc && preloginRes.resetPhoneNumberToken) {
|
|
1274
|
-
yield put(actions.setResetPhoneNumberState({
|
|
1275
|
-
resetPhoneNumberToken: preloginRes.resetPhoneNumberToken,
|
|
1276
|
-
step: ResetPhoneNumberStep.VerifyResetPhoneNumber,
|
|
1277
|
-
}));
|
|
1278
|
-
onRedirectTo(routes.resetPhoneNumberUrl);
|
|
1279
|
-
return;
|
|
1280
|
-
}
|
|
1281
|
-
yield put(actions.setLoginState({
|
|
1282
|
-
step,
|
|
1283
|
-
loading: false,
|
|
1284
|
-
email: payload.email,
|
|
1285
|
-
phoneNumber: preloginRes === null || preloginRes === void 0 ? void 0 : preloginRes.phoneNumber,
|
|
1286
|
-
}));
|
|
1287
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
1288
|
-
}
|
|
1289
|
-
catch (e) {
|
|
1290
|
-
yield put(actions.setLoginState({ error: e.message, loading: false }));
|
|
1291
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
function* passwordlessPostLogin(_a) {
|
|
1295
|
-
var _b, _c;
|
|
1296
|
-
var _d = _a.payload, { callback, events } = _d, payload = __rest(_d, ["callback", "events"]);
|
|
1297
|
-
try {
|
|
1298
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1299
|
-
const data = yield call(api.auth.passwordlessPostLogin, payload);
|
|
1300
|
-
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
1301
|
-
const { routes } = yield select((state) => state.auth);
|
|
1302
|
-
if (isMfaRequired(data)) {
|
|
1303
|
-
const mfaRequiredState = yield getMfaRequiredState(data);
|
|
1304
|
-
yield put(actions.setState(mfaRequiredState));
|
|
1305
|
-
onRedirectTo(routes.loginUrl, { preserveQueryParams: true });
|
|
1306
|
-
}
|
|
1307
|
-
else {
|
|
1308
|
-
const { loginState } = yield select((state) => state.auth);
|
|
1309
|
-
const user = yield call(api.auth.generateLoginResponse, data);
|
|
1310
|
-
if (data.emailVerified) {
|
|
1311
|
-
(_b = events === null || events === void 0 ? void 0 : events.userVerified) === null || _b === void 0 ? void 0 : _b.call(events, {
|
|
1312
|
-
email: user.email,
|
|
1313
|
-
origin: UserVeirifedOriginTypes.PASSWORDLESS,
|
|
1314
|
-
id: user.id,
|
|
1315
|
-
tenantId: user.tenantId,
|
|
1316
|
-
createdAt: new Date(),
|
|
1317
|
-
name: user.name,
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
if (user.email) {
|
|
1321
|
-
localStorage.setItem('email', user.email);
|
|
1322
|
-
}
|
|
1323
|
-
yield put(actions.setState({ user, isAuthenticated: true }));
|
|
1324
|
-
yield put(actions.loadTenants());
|
|
1325
|
-
if (loginState.flow === LoginFlow.Login) {
|
|
1326
|
-
yield afterAuthNavigation();
|
|
1327
|
-
}
|
|
1328
|
-
else {
|
|
1329
|
-
onRedirectTo(routes.loginUrl, { preserveQueryParams: true });
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1333
|
-
}
|
|
1334
|
-
catch (e) {
|
|
1335
|
-
yield put(actions.setLoginState({ error: (_c = e.message) !== null && _c !== void 0 ? _c : 'Failed to authenticate' }));
|
|
1336
|
-
}
|
|
1337
|
-
finally {
|
|
1338
|
-
yield put(actions.setLoginState({ loading: false }));
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
function* verifyInviteToken({ payload }) {
|
|
1342
|
-
var _a;
|
|
1343
|
-
try {
|
|
1344
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1345
|
-
const { name: inviteTokenTenantName } = yield call(api.auth.verifyInviteToken, payload);
|
|
1346
|
-
yield put(actions.setLoginState({ inviteTokenTenantName }));
|
|
1347
|
-
}
|
|
1348
|
-
catch (e) {
|
|
1349
|
-
console.error(e);
|
|
1350
|
-
yield put(actions.setLoginState({ inviteTokenError: (_a = e.message) !== null && _a !== void 0 ? _a : `We couldn't verify your invitation` }));
|
|
1351
|
-
}
|
|
1352
|
-
finally {
|
|
1353
|
-
yield put(actions.setLoginState({ loading: false }));
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
function* preLogin({ payload: { email, recaptchaToken, invitationToken, callback, }, }) {
|
|
1357
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1358
|
-
try {
|
|
1359
|
-
const onRedirectTo = yield select(({ auth: { onRedirectTo } }) => onRedirectTo);
|
|
1360
|
-
let { address, idpType } = yield call(api.auth.preLoginV2, { email });
|
|
1361
|
-
if (address) {
|
|
1362
|
-
if (idpType === SamlVendors.Oidc && !address.includes('redirect_uri')) {
|
|
1363
|
-
const { routes: { oidcRedirectUrl } } = yield select(({ auth: { routes } }) => ({ routes }));
|
|
1364
|
-
address += `&redirect_uri=${window.location.origin}${oidcRedirectUrl}`;
|
|
1365
|
-
}
|
|
1366
|
-
yield put(actions.setLoginState({ step: LoginStep.redirectToSSO, loading: false, ssoRedirectUrl: address }));
|
|
1367
|
-
setTimeout(() => {
|
|
1368
|
-
onRedirectTo(address, { refresh: true });
|
|
1369
|
-
}, 2000);
|
|
1370
|
-
}
|
|
1371
|
-
else {
|
|
1372
|
-
yield ssoPreloginFailed({ email, recaptchaToken, callback, invitationToken });
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
catch (e) {
|
|
1376
|
-
yield ssoPreloginFailed({ email, recaptchaToken, callback, invitationToken });
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
function* ssoPreloginFailed(_a) {
|
|
1380
|
-
var { callback } = _a, body = __rest(_a, ["callback"]);
|
|
1381
|
-
const publicPolicy = yield select(({ auth: { securityPolicyState: { publicPolicy: { policy: publicPolicy } } } }) => publicPolicy);
|
|
1382
|
-
if (!(publicPolicy === null || publicPolicy === void 0 ? void 0 : publicPolicy.authStrategy)) {
|
|
1383
|
-
yield put(actions.setLoginState({ step: LoginStep.loginWithPassword, loading: false }));
|
|
1384
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
1385
|
-
return;
|
|
1386
|
-
}
|
|
1387
|
-
if ((publicPolicy === null || publicPolicy === void 0 ? void 0 : publicPolicy.authStrategy) === AuthStrategyEnum.EmailAndPassword) {
|
|
1388
|
-
yield put(actions.setLoginState({ step: LoginStep.loginWithPassword, loading: false }));
|
|
1389
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
1390
|
-
}
|
|
1391
|
-
else if ([AuthStrategyEnum.MagicLink, AuthStrategyEnum.Code, AuthStrategyEnum.SmsCode].includes(publicPolicy === null || publicPolicy === void 0 ? void 0 : publicPolicy.authStrategy)) {
|
|
1392
|
-
yield put(actions.passwordlessPreLogin(Object.assign(Object.assign({}, body), { type: publicPolicy === null || publicPolicy === void 0 ? void 0 : publicPolicy.authStrategy, callback })));
|
|
1393
|
-
}
|
|
1394
|
-
else {
|
|
1395
|
-
yield put(actions.setLoginState({ step: LoginStep.loginWithPassword, loading: false }));
|
|
1396
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
function* webAuthnCreateNewDeviceSession({ payload: { callback } }) {
|
|
1400
|
-
try {
|
|
1401
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1402
|
-
const { options } = yield call(api.auth.webAuthnCreateNewDeviceSession);
|
|
1403
|
-
options.user.id = base64urlDecode(options.user.id);
|
|
1404
|
-
options.challenge = base64urlDecode(options.challenge);
|
|
1405
|
-
options.excludeCredentials = [];
|
|
1406
|
-
callback === null || callback === void 0 ? void 0 : callback(options);
|
|
1407
|
-
}
|
|
1408
|
-
catch (e) {
|
|
1409
|
-
yield put(actions.setLoginState({ error: e.message }));
|
|
1410
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
1411
|
-
}
|
|
1412
|
-
finally {
|
|
1413
|
-
yield put(actions.setLoginState({ loading: false }));
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
function* webAuthnVerifyNewDeviceSession(_a) {
|
|
1417
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
1418
|
-
try {
|
|
1419
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1420
|
-
const publicKey = publicKeyCredentialToJSON(body.publicKey);
|
|
1421
|
-
yield call(api.auth.verifyNewDeviceSession, {
|
|
1422
|
-
id: publicKey.id,
|
|
1423
|
-
response: publicKey.response
|
|
1424
|
-
});
|
|
1425
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1426
|
-
}
|
|
1427
|
-
catch (e) {
|
|
1428
|
-
yield put(actions.setLoginState({ error: e.message }));
|
|
1429
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
1430
|
-
}
|
|
1431
|
-
finally {
|
|
1432
|
-
yield put(actions.setLoginState({ loading: false }));
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
function* webAuthnPrelogin(_a) {
|
|
1436
|
-
var _b;
|
|
1437
|
-
var _c = _a.payload, { callback } = _c, body = __rest(_c, ["callback"]);
|
|
1438
|
-
try {
|
|
1439
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1440
|
-
const { options } = yield call(api.auth.webAuthnPreLogin, body);
|
|
1441
|
-
options.challenge = base64urlDecode(options.challenge);
|
|
1442
|
-
options.allowCredentials = (_b = options.allowCredentials) === null || _b === void 0 ? void 0 : _b.map((credentials) => (Object.assign(Object.assign({}, credentials), { id: base64urlDecode(credentials.id) })));
|
|
1443
|
-
callback === null || callback === void 0 ? void 0 : callback(options);
|
|
1444
|
-
}
|
|
1445
|
-
catch (e) {
|
|
1446
|
-
yield put(actions.setLoginState({ error: e.message }));
|
|
1447
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
1448
|
-
}
|
|
1449
|
-
finally {
|
|
1450
|
-
yield put(actions.setLoginState({ loading: false }));
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
function* webAuthnPostLogin(_a) {
|
|
1454
|
-
var _b;
|
|
1455
|
-
var _c = _a.payload, { callback } = _c, body = __rest(_c, ["callback"]);
|
|
1456
|
-
try {
|
|
1457
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1458
|
-
const publicKey = publicKeyCredentialToJSON(body.publicKey);
|
|
1459
|
-
const data = yield call(api.auth.webAuthnPostLogin, Object.assign(Object.assign({}, publicKey), { response: Object.assign(Object.assign({}, publicKey.response), { userHandle: (_b = publicKey.response.userHandle) !== null && _b !== void 0 ? _b : undefined }), recaptchaToken: body.recaptchaToken, invitationToken: body.invitationToken }));
|
|
1460
|
-
if (isMfaRequired(data)) {
|
|
1461
|
-
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
1462
|
-
const { routes } = yield select((state) => state.auth);
|
|
1463
|
-
const mfaRequiredState = yield getMfaRequiredState(data);
|
|
1464
|
-
yield put(actions.setState(mfaRequiredState));
|
|
1465
|
-
onRedirectTo(routes.loginUrl, { preserveQueryParams: true });
|
|
1466
|
-
}
|
|
1467
|
-
else {
|
|
1468
|
-
const user = yield call(api.auth.generateLoginResponse, data);
|
|
1469
|
-
yield put(actions.loadTenants());
|
|
1470
|
-
yield put(actions.setState({ user, isAuthenticated: true }));
|
|
1471
|
-
yield afterAuthNavigation();
|
|
1472
|
-
}
|
|
1473
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1474
|
-
}
|
|
1475
|
-
catch (e) {
|
|
1476
|
-
yield put(actions.setLoginState({ error: e.message }));
|
|
1477
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
1478
|
-
}
|
|
1479
|
-
finally {
|
|
1480
|
-
yield put(actions.setLoginState({ loading: false }));
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
function* postLogin({ payload }) {
|
|
1484
|
-
const { onRedirectTo, routes } = yield select(({ auth: { onRedirectTo, routes } }) => ({ onRedirectTo, routes }));
|
|
1485
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1486
|
-
try {
|
|
1487
|
-
const user = yield call(api.auth.postLogin, payload);
|
|
1488
|
-
ContextHolder.setAccessToken(user.accessToken);
|
|
1489
|
-
ContextHolder.setUser(user);
|
|
1490
|
-
yield put(actions.setState({
|
|
1491
|
-
user: !!user.accessToken ? user : undefined,
|
|
1492
|
-
isAuthenticated: !!user.accessToken,
|
|
1493
|
-
}));
|
|
1494
|
-
yield afterAuthNavigation();
|
|
1495
|
-
}
|
|
1496
|
-
catch (e) {
|
|
1497
|
-
setTimeout(() => {
|
|
1498
|
-
onRedirectTo(routes.authenticatedUrl);
|
|
1499
|
-
}, 1000);
|
|
1500
|
-
yield put(actions.setLoginState({ step: LoginStep.loginWithSSOFailed, loading: false }));
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
function* login({ payload: { email, password, recaptchaToken, invitationToken, callback, }, }) {
|
|
1504
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1505
|
-
try {
|
|
1506
|
-
const user = yield call(api.auth.login, {
|
|
1507
|
-
email,
|
|
1508
|
-
password,
|
|
1509
|
-
recaptchaToken,
|
|
1510
|
-
invitationToken,
|
|
1511
|
-
});
|
|
1512
|
-
ContextHolder.setAccessToken(user.accessToken);
|
|
1513
|
-
ContextHolder.setUser(user);
|
|
1514
|
-
let setMfaState = {};
|
|
1515
|
-
let step = LoginStep.success;
|
|
1516
|
-
if (user.mfaRequired && user.mfaToken) {
|
|
1517
|
-
step = LoginStep.loginWithTwoFactor;
|
|
1518
|
-
if (user.hasOwnProperty('mfaEnrolled') && !user.mfaEnrolled) {
|
|
1519
|
-
setMfaState = {
|
|
1520
|
-
mfaState: {
|
|
1521
|
-
step: MFAStep.verify,
|
|
1522
|
-
qrCode: user.qrCode,
|
|
1523
|
-
recoveryCode: user.recoveryCode,
|
|
1524
|
-
mfaToken: user.mfaToken,
|
|
1525
|
-
loading: false,
|
|
1526
|
-
},
|
|
1527
|
-
};
|
|
1528
|
-
step = LoginStep.forceTwoFactor;
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
const { loginState } = yield select((state) => state.auth);
|
|
1532
|
-
const isLoginSucceeded = step === LoginStep.success;
|
|
1533
|
-
const isAuthenticated = isLoginSucceeded && !!user.accessToken;
|
|
1534
|
-
const loggedInUser = isLoginSucceeded ? user : undefined;
|
|
1535
|
-
let allowRememberDevice = { isAllowedToRemember: false, mfaDeviceExpiration: 0 };
|
|
1536
|
-
if (user.mfaRequired && user.mfaToken) {
|
|
1537
|
-
allowRememberDevice = yield call(api.auth.checkIfAllowToRememberMfaDevice, user.mfaToken);
|
|
1538
|
-
}
|
|
1539
|
-
const { isAllowedToRemember, mfaDeviceExpiration } = allowRememberDevice;
|
|
1540
|
-
if (user.email) {
|
|
1541
|
-
localStorage.setItem('email', user.email);
|
|
1542
|
-
}
|
|
1543
|
-
yield put(actions.setState(Object.assign(Object.assign({ user: loggedInUser, isAuthenticated }, setMfaState), { loginState: {
|
|
1544
|
-
flow: loginState.flow,
|
|
1545
|
-
quickLoginToRegister: loginState.quickLoginToRegister,
|
|
1546
|
-
email,
|
|
1547
|
-
loading: false,
|
|
1548
|
-
error: undefined,
|
|
1549
|
-
mfaToken: user.mfaToken,
|
|
1550
|
-
step: (!isLoginSucceeded || loginState.flow === LoginFlow.Login) ? step : loginState.step,
|
|
1551
|
-
tenants: [],
|
|
1552
|
-
tenantsLoading: true,
|
|
1553
|
-
allowRememberMfaDevice: isAllowedToRemember,
|
|
1554
|
-
mfaDeviceExpiration,
|
|
1555
|
-
} })));
|
|
1556
|
-
if (isLoginSucceeded) {
|
|
1557
|
-
yield put(actions.loadTenants());
|
|
1558
|
-
}
|
|
1559
|
-
if (isAuthenticated && loginState.flow === LoginFlow.Login) {
|
|
1560
|
-
yield afterAuthNavigation();
|
|
1561
|
-
}
|
|
1562
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1563
|
-
}
|
|
1564
|
-
catch (e) {
|
|
1565
|
-
ContextHolder.setAccessToken(null);
|
|
1566
|
-
ContextHolder.setUser(null);
|
|
1567
|
-
yield put(actions.setLoginState({
|
|
1568
|
-
email,
|
|
1569
|
-
error: e.message,
|
|
1570
|
-
loading: false,
|
|
1571
|
-
}));
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
function* loginWithMfa({ payload: { mfaToken, value, rememberDevice, callback }, }) {
|
|
1575
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1576
|
-
try {
|
|
1577
|
-
const user = yield call(api.auth.loginWithMfa, { mfaToken, value, rememberDevice });
|
|
1578
|
-
const { loginState } = yield select((state) => state.auth);
|
|
1579
|
-
const step = loginState.flow === LoginFlow.Login ? LoginStep.success : loginState.step;
|
|
1580
|
-
yield put(actions.setState({
|
|
1581
|
-
loginState: { flow: loginState.flow, quickLoginToRegister: loginState.quickLoginToRegister, loading: false, step, error: undefined, tenantsLoading: true, tenants: [] },
|
|
1582
|
-
user,
|
|
1583
|
-
isAuthenticated: true,
|
|
1584
|
-
}));
|
|
1585
|
-
if (user.email) {
|
|
1586
|
-
localStorage.setItem('email', user.email);
|
|
1587
|
-
}
|
|
1588
|
-
yield put(actions.loadTenants());
|
|
1589
|
-
if (loginState.flow === LoginFlow.Login) {
|
|
1590
|
-
yield afterAuthNavigation();
|
|
1591
|
-
}
|
|
1592
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1593
|
-
}
|
|
1594
|
-
catch (e) {
|
|
1595
|
-
yield put(actions.setLoginState({ error: e.message, loading: false }));
|
|
1596
|
-
callback === null || callback === void 0 ? void 0 : callback(false, e);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
function* recoverMfa({ payload }) {
|
|
1600
|
-
yield put(actions.setLoginState({ loading: true }));
|
|
1601
|
-
try {
|
|
1602
|
-
yield call(api.auth.recoverMfaToken, payload);
|
|
1603
|
-
yield put(actions.setLoginState({ loading: false, error: undefined, step: LoginStep.preLogin }));
|
|
1604
|
-
yield put(actions.setState({ user: undefined, isAuthenticated: false }));
|
|
1605
|
-
}
|
|
1606
|
-
catch (e) {
|
|
1607
|
-
yield put(actions.setLoginState({ error: e.message, loading: false }));
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
function* logout({ payload }) {
|
|
1611
|
-
yield put(actions.setState({ isLoading: true }));
|
|
1612
|
-
try {
|
|
1613
|
-
yield call(api.auth.logout);
|
|
1614
|
-
}
|
|
1615
|
-
catch (_a) {
|
|
1616
|
-
}
|
|
1617
|
-
yield put(actions.resetState());
|
|
1618
|
-
yield put(actions.requestAuthorize(true));
|
|
1619
|
-
payload === null || payload === void 0 ? void 0 : payload();
|
|
1620
|
-
}
|
|
1621
|
-
function* silentLogout({ payload }) {
|
|
1622
|
-
try {
|
|
1623
|
-
yield call(api.auth.logout);
|
|
1624
|
-
}
|
|
1625
|
-
catch (_a) {
|
|
1626
|
-
}
|
|
1627
|
-
setTimeout(() => payload === null || payload === void 0 ? void 0 : payload(), 500);
|
|
1628
|
-
}
|
|
1629
|
-
function* loginSagas() {
|
|
1630
|
-
yield takeLeading(actions.requestAuthorize, requestAuthorize);
|
|
1631
|
-
yield takeLeading(actions.requestAuthorizeSSR, requestAuthorizeSSR);
|
|
1632
|
-
yield takeLeading(actions.requestHostedLoginAuthorize, requestHostedLoginAuthorize);
|
|
1633
|
-
yield takeLeading(actions.handleHostedLoginCallback, handleHostedLoginCallback);
|
|
1634
|
-
yield takeLeading(actions.preLogin, preLogin);
|
|
1635
|
-
yield takeLeading(actions.postLogin, postLogin);
|
|
1636
|
-
yield takeLeading(actions.login, login);
|
|
1637
|
-
yield takeLeading(actions.logout, logout);
|
|
1638
|
-
yield takeLeading(actions.silentLogout, silentLogout);
|
|
1639
|
-
yield takeLeading(actions.loginWithMfa, loginWithMfa);
|
|
1640
|
-
yield takeLeading(actions.recoverMfa, recoverMfa);
|
|
1641
|
-
yield takeLeading(actions.passwordlessPreLogin, passwordlessPreLogin);
|
|
1642
|
-
yield takeLeading(actions.passwordlessPostLogin, passwordlessPostLogin);
|
|
1643
|
-
yield takeLeading(actions.verifyInviteToken, verifyInviteToken);
|
|
1644
|
-
yield takeLeading(actions.webAuthnPrelogin, webAuthnPrelogin);
|
|
1645
|
-
yield takeLeading(actions.webAuthnPostLogin, webAuthnPostLogin);
|
|
1646
|
-
yield takeLeading(actions.webAuthnCreateNewDeviceSession, webAuthnCreateNewDeviceSession);
|
|
1647
|
-
yield takeLeading(actions.webAuthnVerifyNewDeviceSession, webAuthnVerifyNewDeviceSession);
|
|
1648
|
-
yield takeLeading(actions.afterAuthNavigation, afterAuthNavigation);
|
|
1649
|
-
}
|
|
1650
|
-
/*********************************
|
|
1651
|
-
* Preview Sagas
|
|
1652
|
-
*********************************/
|
|
1653
|
-
function* requestAuthorizeMock({ payload: firstTime }) {
|
|
1654
|
-
if (firstTime) {
|
|
1655
|
-
yield put(actions.setState({ isLoading: true }));
|
|
1656
|
-
}
|
|
1657
|
-
const user = userDemo;
|
|
1658
|
-
yield put(actions.loadTenants());
|
|
1659
|
-
yield put(actions.setState({ user, isAuthenticated: true, isLoading: false }));
|
|
1660
|
-
}
|
|
1661
|
-
function* loginSagasMock() {
|
|
1662
|
-
yield takeLeading(actions.requestAuthorize, requestAuthorizeMock);
|
|
1663
|
-
yield takeLeading(actions.afterAuthNavigation, afterAuthNavigation);
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
function* loadSSOConfigurations() {
|
|
1667
|
-
var _a, _b;
|
|
1668
|
-
try {
|
|
1669
|
-
yield put(actions.setSSOState({ loading: true }));
|
|
1670
|
-
const samlConfiguration = yield call(api.auth.getSamlConfiguration);
|
|
1671
|
-
const oidcConfiguration = yield call(api.auth.getOidcConfiguration);
|
|
1672
|
-
const samlMetadata = yield call(api.metadata.getSamlMetadata);
|
|
1673
|
-
samlConfiguration.acsUrl = (_a = samlMetadata === null || samlMetadata === void 0 ? void 0 : samlMetadata.configuration) === null || _a === void 0 ? void 0 : _a.acsUrl;
|
|
1674
|
-
samlConfiguration.spEntityId = (_b = samlMetadata === null || samlMetadata === void 0 ? void 0 : samlMetadata.configuration) === null || _b === void 0 ? void 0 : _b.spEntityId;
|
|
1675
|
-
samlConfiguration.isSamlActive = samlMetadata === null || samlMetadata === void 0 ? void 0 : samlMetadata.isActive;
|
|
1676
|
-
yield put(actions.setSSOState({ samlConfiguration, oidcConfiguration, loading: false, firstLoad: false }));
|
|
1677
|
-
}
|
|
1678
|
-
catch (e) {
|
|
1679
|
-
yield put(actions.setSSOState({ error: e.message, loading: false }));
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
function* saveSSOConfigurationsFile({ payload: configFile }) {
|
|
1683
|
-
const oldSamlConfiguration = yield select((state) => state.auth.ssoState.samlConfiguration);
|
|
1684
|
-
const loaderKey = 'saving';
|
|
1685
|
-
yield put(actions.setSSOState({ error: undefined, [loaderKey]: true }));
|
|
1686
|
-
try {
|
|
1687
|
-
const metadata = yield readFileAsText(configFile[0]);
|
|
1688
|
-
const newSamlConfiguration = yield call(api.auth.updateSamlVendorMetadata, { metadata });
|
|
1689
|
-
newSamlConfiguration.isSamlActive = oldSamlConfiguration === null || oldSamlConfiguration === void 0 ? void 0 : oldSamlConfiguration.isSamlActive;
|
|
1690
|
-
yield put(actions.setSSOState({ samlConfiguration: newSamlConfiguration, error: undefined, [loaderKey]: false }));
|
|
1691
|
-
}
|
|
1692
|
-
catch (e) {
|
|
1693
|
-
yield put(actions.setSSOState({ samlConfiguration: oldSamlConfiguration, error: e.message, [loaderKey]: false }));
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
function* saveSSOConfigurationsFileWithCallback({ payload }) {
|
|
1697
|
-
const { configFile, callback } = payload;
|
|
1698
|
-
const oldSamlConfiguration = yield select((state) => state.auth.ssoState.samlConfiguration);
|
|
1699
|
-
const loaderKey = 'saving';
|
|
1700
|
-
yield put(actions.setSSOState({ error: undefined, [loaderKey]: true }));
|
|
1701
|
-
try {
|
|
1702
|
-
const metadata = yield readFileAsText(configFile);
|
|
1703
|
-
const newSamlConfiguration = yield call(api.auth.updateSamlVendorMetadata, { metadata });
|
|
1704
|
-
newSamlConfiguration.isSamlActive = oldSamlConfiguration === null || oldSamlConfiguration === void 0 ? void 0 : oldSamlConfiguration.isSamlActive;
|
|
1705
|
-
yield put(actions.setSSOState({ samlConfiguration: newSamlConfiguration, error: undefined, [loaderKey]: false }));
|
|
1706
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1707
|
-
}
|
|
1708
|
-
catch (e) {
|
|
1709
|
-
yield put(actions.setSSOState({ samlConfiguration: oldSamlConfiguration, error: e.message, [loaderKey]: false }));
|
|
1710
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
function* saveSSOConfigurations({ payload }) {
|
|
1714
|
-
var _a, _b;
|
|
1715
|
-
const { callback, samlVendor } = payload, newSamlConfiguration = __rest(payload, ["callback", "samlVendor"]);
|
|
1716
|
-
const oldSamlConfiguration = yield select((state) => state.auth.ssoState.samlConfiguration);
|
|
1717
|
-
const samlConfiguration = Object.assign(Object.assign({}, oldSamlConfiguration), newSamlConfiguration);
|
|
1718
|
-
let loaderKey = 'saving';
|
|
1719
|
-
if ((samlConfiguration === null || samlConfiguration === void 0 ? void 0 : samlConfiguration.enabled) !== oldSamlConfiguration.enabled) {
|
|
1720
|
-
loaderKey = 'loading';
|
|
1721
|
-
}
|
|
1722
|
-
try {
|
|
1723
|
-
const firstTimeConfigure = !(samlConfiguration === null || samlConfiguration === void 0 ? void 0 : samlConfiguration.domain);
|
|
1724
|
-
if (firstTimeConfigure) {
|
|
1725
|
-
yield put(actions.setSSOState({ samlConfiguration: Object.assign(Object.assign({}, oldSamlConfiguration), samlConfiguration) }));
|
|
1726
|
-
return;
|
|
1727
|
-
}
|
|
1728
|
-
else {
|
|
1729
|
-
yield put(actions.setSSOState({ error: undefined, [loaderKey]: true }));
|
|
1730
|
-
}
|
|
1731
|
-
if (payload.type === SamlVendors.Saml) {
|
|
1732
|
-
const samlMetadata = yield call(api.metadata.getSamlMetadata);
|
|
1733
|
-
samlConfiguration.acsUrl = (_a = samlMetadata === null || samlMetadata === void 0 ? void 0 : samlMetadata.configuration) === null || _a === void 0 ? void 0 : _a.acsUrl;
|
|
1734
|
-
samlConfiguration.spEntityId = (_b = samlMetadata === null || samlMetadata === void 0 ? void 0 : samlMetadata.configuration) === null || _b === void 0 ? void 0 : _b.spEntityId;
|
|
1735
|
-
}
|
|
1736
|
-
const updateSamlConfiguration = omitProps(samlConfiguration, [
|
|
1737
|
-
'validated',
|
|
1738
|
-
'generatedVerification',
|
|
1739
|
-
'createdAt',
|
|
1740
|
-
'updatedAt',
|
|
1741
|
-
]);
|
|
1742
|
-
if ((oldSamlConfiguration === null || oldSamlConfiguration === void 0 ? void 0 : oldSamlConfiguration.domain) !== (updateSamlConfiguration === null || updateSamlConfiguration === void 0 ? void 0 : updateSamlConfiguration.domain)) {
|
|
1743
|
-
updateSamlConfiguration.ssoEndpoint = '';
|
|
1744
|
-
updateSamlConfiguration.publicCertificate = '';
|
|
1745
|
-
updateSamlConfiguration.signRequest = false;
|
|
1746
|
-
}
|
|
1747
|
-
updateSamlConfiguration.type = samlVendor === null || samlVendor === void 0 ? void 0 : samlVendor.toLowerCase();
|
|
1748
|
-
const newSamlConfiguration = yield call(api.auth.updateSamlConfiguration, updateSamlConfiguration);
|
|
1749
|
-
newSamlConfiguration.isSamlActive = oldSamlConfiguration === null || oldSamlConfiguration === void 0 ? void 0 : oldSamlConfiguration.isSamlActive;
|
|
1750
|
-
yield put(actions.setSSOState({ samlConfiguration: newSamlConfiguration, error: undefined, [loaderKey]: false }));
|
|
1751
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1752
|
-
}
|
|
1753
|
-
catch (e) {
|
|
1754
|
-
yield put(actions.setSSOState({ samlConfiguration: oldSamlConfiguration, error: e.message, [loaderKey]: false }));
|
|
1755
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
function* validateSSODomain({ payload: { callback } = {} }) {
|
|
1759
|
-
const samlConfiguration = yield select((state) => state.auth.ssoState.samlConfiguration);
|
|
1760
|
-
try {
|
|
1761
|
-
yield put(actions.setSSOState({ error: undefined, saving: true }));
|
|
1762
|
-
yield call(api.auth.validateSamlDomain);
|
|
1763
|
-
yield put(actions.setSSOState({
|
|
1764
|
-
samlConfiguration: Object.assign(Object.assign({}, samlConfiguration), { validated: true }),
|
|
1765
|
-
error: undefined,
|
|
1766
|
-
saving: false,
|
|
1767
|
-
}));
|
|
1768
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1769
|
-
}
|
|
1770
|
-
catch (e) {
|
|
1771
|
-
yield put(actions.setSSOState({
|
|
1772
|
-
samlConfiguration: Object.assign(Object.assign({}, samlConfiguration), { validated: false }),
|
|
1773
|
-
error: e.message,
|
|
1774
|
-
saving: false,
|
|
1775
|
-
}));
|
|
1776
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1779
|
-
function* getAuthorizationRoles() {
|
|
1780
|
-
try {
|
|
1781
|
-
const data = yield call(api.auth.getSamlRoles);
|
|
1782
|
-
const groupsData = yield call(api.auth.getSamlRolesGroups);
|
|
1783
|
-
yield put(actions.setSSOState({
|
|
1784
|
-
authorizationRoles: data.roleIds,
|
|
1785
|
-
rolesGroups: groupsData,
|
|
1786
|
-
error: undefined,
|
|
1787
|
-
}));
|
|
1788
|
-
}
|
|
1789
|
-
catch (e) {
|
|
1790
|
-
yield put(actions.setSSOState({
|
|
1791
|
-
error: e.message,
|
|
1792
|
-
}));
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
function* updateRolesGroups(groups) {
|
|
1796
|
-
try {
|
|
1797
|
-
yield all(groups.map((group) => call(api.auth.updateSamlGroup, { id: group.id, roleIds: group.roleIds, group: group.group })));
|
|
1798
|
-
}
|
|
1799
|
-
catch (e) {
|
|
1800
|
-
yield put(actions.setSSOState({
|
|
1801
|
-
error: e.message,
|
|
1802
|
-
}));
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
function* updateAuthorizationRoles({ payload: { callback, authorizationRoles, groups }, }) {
|
|
1806
|
-
try {
|
|
1807
|
-
yield put(actions.setSSOState({ error: undefined, saving: true }));
|
|
1808
|
-
yield call(api.auth.updateSamlRoles, { roleIds: authorizationRoles });
|
|
1809
|
-
if (groups) {
|
|
1810
|
-
yield updateRolesGroups(groups);
|
|
1811
|
-
}
|
|
1812
|
-
yield getAuthorizationRoles();
|
|
1813
|
-
yield put(actions.setSSOState({ error: undefined, saving: false }));
|
|
1814
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1815
|
-
}
|
|
1816
|
-
catch (e) {
|
|
1817
|
-
yield put(actions.setSSOState({
|
|
1818
|
-
error: e.message,
|
|
1819
|
-
saving: false,
|
|
1820
|
-
}));
|
|
1821
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
function* deleteSamlGroupFunction({ payload: { callback, id } }) {
|
|
1825
|
-
try {
|
|
1826
|
-
yield put(actions.setSSOState({ error: undefined, saving: true }));
|
|
1827
|
-
yield call(api.auth.deleteSamlGroup, { id });
|
|
1828
|
-
yield getAuthorizationRoles();
|
|
1829
|
-
yield put(actions.setSSOState({ error: undefined, saving: false }));
|
|
1830
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1831
|
-
}
|
|
1832
|
-
catch (e) {
|
|
1833
|
-
yield put(actions.setSSOState({
|
|
1834
|
-
error: e.message,
|
|
1835
|
-
saving: false,
|
|
1836
|
-
}));
|
|
1837
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
function* createSamlGroupFunction({ payload: { group, roleIds, callback } }) {
|
|
1841
|
-
try {
|
|
1842
|
-
yield put(actions.setSSOState({ error: undefined, saving: true }));
|
|
1843
|
-
yield call(api.auth.createSamlGroup, { group, roleIds });
|
|
1844
|
-
yield getAuthorizationRoles();
|
|
1845
|
-
yield put(actions.setSSOState({ error: undefined, saving: false }));
|
|
1846
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1847
|
-
}
|
|
1848
|
-
catch (e) {
|
|
1849
|
-
yield put(actions.setSSOState({
|
|
1850
|
-
error: e.message,
|
|
1851
|
-
saving: false,
|
|
1852
|
-
}));
|
|
1853
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
function* oidcPostloginFunction({ payload }) {
|
|
1857
|
-
var _a;
|
|
1858
|
-
const data = { code: payload.code, redirectUri: payload.redirectUri, RelayState: payload.state };
|
|
1859
|
-
try {
|
|
1860
|
-
yield put(actions.setSSOState({ loading: true }));
|
|
1861
|
-
yield call(api.auth.oidcPostLoginV2, data);
|
|
1862
|
-
yield refreshToken();
|
|
1863
|
-
yield put(actions.setSSOState({ loading: false }));
|
|
1864
|
-
}
|
|
1865
|
-
catch (e) {
|
|
1866
|
-
yield put(actions.setSSOState({ loading: false, error: (_a = e.message) !== null && _a !== void 0 ? _a : 'Failed to authenticate', firstLoad: false }));
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
function* ssoSagas$1() {
|
|
1870
|
-
yield takeEvery(actions.loadSSOConfigurations, loadSSOConfigurations);
|
|
1871
|
-
yield takeEvery(actions.saveSSOConfigurations, saveSSOConfigurations);
|
|
1872
|
-
yield takeEvery(actions.saveSSOConfigurationsFile, saveSSOConfigurationsFile);
|
|
1873
|
-
yield takeEvery(actions.saveSSOConfigurationsFileWithCallback, saveSSOConfigurationsFileWithCallback);
|
|
1874
|
-
yield takeEvery(actions.validateSSODomain, validateSSODomain);
|
|
1875
|
-
yield takeEvery(actions.loadSSOAuthorizationRoles, getAuthorizationRoles);
|
|
1876
|
-
yield takeEvery(actions.updateSSOAuthorizationRoles, updateAuthorizationRoles);
|
|
1877
|
-
yield takeEvery(actions.deleteSamlGroup, deleteSamlGroupFunction);
|
|
1878
|
-
yield takeEvery(actions.createSamlGroup, createSamlGroupFunction);
|
|
1879
|
-
yield takeEvery(actions.oidcPostlogin, oidcPostloginFunction);
|
|
1880
|
-
}
|
|
1881
|
-
/*********************************
|
|
1882
|
-
* Preview Sagas
|
|
1883
|
-
*********************************/
|
|
1884
|
-
function* loadSSOConfigurationsMock() {
|
|
1885
|
-
yield put(actions.setSSOState({ loading: true }));
|
|
1886
|
-
yield delay();
|
|
1887
|
-
yield put(actions.setSSOState({ samlConfiguration: samlConfigurationDemo, loading: false, firstLoad: false }));
|
|
1888
|
-
}
|
|
1889
|
-
function* saveSSOConfigurationsFileMock({ payload: configFile }) {
|
|
1890
|
-
const loaderKey = 'saving';
|
|
1891
|
-
yield put(actions.setSSOState({ error: undefined, [loaderKey]: true }));
|
|
1892
|
-
const oldSamlConfiguration = yield select((state) => state.auth.ssoState.samlConfiguration);
|
|
1893
|
-
const newSamlConfiguration = Object.assign(Object.assign(Object.assign({}, oldSamlConfiguration), { enabled: true }), configFile[0]);
|
|
1894
|
-
yield put(actions.setSSOState({ samlConfiguration: newSamlConfiguration, error: undefined, [loaderKey]: false }));
|
|
1895
|
-
}
|
|
1896
|
-
function* saveSSOConfigurationsMock({ payload }) {
|
|
1897
|
-
var _a, _b;
|
|
1898
|
-
const { callback, samlVendor } = payload, newSamlConfiguration = __rest(payload, ["callback", "samlVendor"]);
|
|
1899
|
-
const oldSamlConfiguration = ssoStateDemo.samlConfiguration;
|
|
1900
|
-
const samlConfiguration = Object.assign(Object.assign({}, oldSamlConfiguration), newSamlConfiguration);
|
|
1901
|
-
let loaderKey = 'saving';
|
|
1902
|
-
if ((samlConfiguration === null || samlConfiguration === void 0 ? void 0 : samlConfiguration.enabled) !== oldSamlConfiguration.enabled) {
|
|
1903
|
-
loaderKey = 'loading';
|
|
1904
|
-
}
|
|
1905
|
-
const firstTimeConfigure = !(samlConfiguration === null || samlConfiguration === void 0 ? void 0 : samlConfiguration.domain);
|
|
1906
|
-
if (firstTimeConfigure) {
|
|
1907
|
-
yield put(actions.setSSOState({ samlConfiguration: Object.assign(Object.assign({}, oldSamlConfiguration), samlConfiguration) }));
|
|
1908
|
-
return;
|
|
1909
|
-
}
|
|
1910
|
-
else {
|
|
1911
|
-
yield put(actions.setSSOState({ error: undefined, [loaderKey]: true }));
|
|
1912
|
-
}
|
|
1913
|
-
yield delay();
|
|
1914
|
-
samlConfiguration.acsUrl = (_a = samlMetadataDemo === null || samlMetadataDemo === void 0 ? void 0 : samlMetadataDemo.configuration) === null || _a === void 0 ? void 0 : _a.acsUrl;
|
|
1915
|
-
samlConfiguration.spEntityId = (_b = samlMetadataDemo === null || samlMetadataDemo === void 0 ? void 0 : samlMetadataDemo.configuration) === null || _b === void 0 ? void 0 : _b.spEntityId;
|
|
1916
|
-
const updateSamlConfiguration = omitProps(samlConfiguration, [
|
|
1917
|
-
'validated',
|
|
1918
|
-
'generatedVerification',
|
|
1919
|
-
'createdAt',
|
|
1920
|
-
'updatedAt',
|
|
1921
|
-
]);
|
|
1922
|
-
if ((oldSamlConfiguration === null || oldSamlConfiguration === void 0 ? void 0 : oldSamlConfiguration.domain) !== (updateSamlConfiguration === null || updateSamlConfiguration === void 0 ? void 0 : updateSamlConfiguration.domain)) {
|
|
1923
|
-
updateSamlConfiguration.ssoEndpoint = '';
|
|
1924
|
-
updateSamlConfiguration.publicCertificate = '';
|
|
1925
|
-
updateSamlConfiguration.signRequest = false;
|
|
1926
|
-
}
|
|
1927
|
-
updateSamlConfiguration.type = samlVendor === null || samlVendor === void 0 ? void 0 : samlVendor.toLowerCase();
|
|
1928
|
-
yield delay();
|
|
1929
|
-
yield put(actions.setSSOState({ samlConfiguration: updateSamlConfiguration, error: undefined, [loaderKey]: false }));
|
|
1930
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1931
|
-
}
|
|
1932
|
-
function* validateSSODomainMock({ payload: { callback } = {} }) {
|
|
1933
|
-
const samlConfiguration = ssoStateDemo.samlConfiguration;
|
|
1934
|
-
yield put(actions.setSSOState({ error: undefined, saving: true }));
|
|
1935
|
-
yield delay();
|
|
1936
|
-
yield put(actions.setSSOState({
|
|
1937
|
-
samlConfiguration: Object.assign(Object.assign({}, samlConfiguration), { validated: true }),
|
|
1938
|
-
error: undefined,
|
|
1939
|
-
saving: false,
|
|
1940
|
-
}));
|
|
1941
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1942
|
-
}
|
|
1943
|
-
function* getAuthorizationRolesMock() {
|
|
1944
|
-
yield delay();
|
|
1945
|
-
const data = { roleIds: ['1', '2', '3'] };
|
|
1946
|
-
yield put(actions.setSSOState({
|
|
1947
|
-
authorizationRoles: data.roleIds,
|
|
1948
|
-
error: undefined,
|
|
1949
|
-
}));
|
|
1950
|
-
}
|
|
1951
|
-
function* updateAuthorizationRolesMock({ payload: { callback, authorizationRoles }, }) {
|
|
1952
|
-
yield put(actions.setSSOState({ error: undefined, saving: true }));
|
|
1953
|
-
yield delay();
|
|
1954
|
-
yield put(actions.setSSOState({ authorizationRoles, error: undefined, saving: false }));
|
|
1955
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
1956
|
-
}
|
|
1957
|
-
function* ssoSagasMock() {
|
|
1958
|
-
yield takeEvery(actions.loadSSOConfigurations, loadSSOConfigurationsMock);
|
|
1959
|
-
yield takeEvery(actions.saveSSOConfigurations, saveSSOConfigurationsMock);
|
|
1960
|
-
yield takeEvery(actions.saveSSOConfigurationsFile, saveSSOConfigurationsFileMock);
|
|
1961
|
-
yield takeEvery(actions.validateSSODomain, validateSSODomainMock);
|
|
1962
|
-
yield takeEvery(actions.loadSSOAuthorizationRoles, getAuthorizationRolesMock);
|
|
1963
|
-
yield takeEvery(actions.updateSSOAuthorizationRoles, updateAuthorizationRolesMock);
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
function* loadOidc() {
|
|
1967
|
-
try {
|
|
1968
|
-
const oidcConfiguration = yield call(api.auth.getOidcConfiguration);
|
|
1969
|
-
return oidcConfiguration;
|
|
1970
|
-
}
|
|
1971
|
-
catch (e) {
|
|
1972
|
-
return null;
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
function* loadSaml() {
|
|
1976
|
-
try {
|
|
1977
|
-
const samlMetadata = yield call(api.metadata.getSamlMetadata);
|
|
1978
|
-
return samlMetadata;
|
|
1979
|
-
}
|
|
1980
|
-
catch (e) {
|
|
1981
|
-
return null;
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
function* loadSSOConfigurationsV2() {
|
|
1985
|
-
try {
|
|
1986
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.LOAD_SSO_CONFIGURATIONS, value: true }));
|
|
1987
|
-
const [oidcConfiguration, samlMetadata] = yield all([call(loadOidc), call(loadSaml)]);
|
|
1988
|
-
const ssoConfigurations = yield call(api.auth.getSSOConfigurations);
|
|
1989
|
-
yield put(actions.setSSOState({
|
|
1990
|
-
ssoConfigurations,
|
|
1991
|
-
oidcConfiguration,
|
|
1992
|
-
samlMetadata
|
|
1993
|
-
}));
|
|
1994
|
-
}
|
|
1995
|
-
catch (error) {
|
|
1996
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.LOAD_SSO_CONFIGURATIONS, value: error.message }));
|
|
1997
|
-
}
|
|
1998
|
-
finally {
|
|
1999
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.LOAD_SSO_CONFIGURATIONS, value: false }));
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
function* saveSSOConfigurationV2({ payload }) {
|
|
2003
|
-
var _a;
|
|
2004
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_CONFIGURATION, value: true }));
|
|
2005
|
-
const { callback } = payload, ssoConfiguration = __rest(payload, ["callback"]);
|
|
2006
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2007
|
-
try {
|
|
2008
|
-
const newSsoConfiguration = yield call(api.auth.createSSOConfiguration, Object.assign(Object.assign({}, ssoConfiguration), { enabled: (_a = ssoConfiguration.enabled) !== null && _a !== void 0 ? _a : false }));
|
|
2009
|
-
yield put(actions.setSSOState({ ssoConfigurations: [...ssoConfigurations, newSsoConfiguration] }));
|
|
2010
|
-
callback === null || callback === void 0 ? void 0 : callback(newSsoConfiguration);
|
|
2011
|
-
}
|
|
2012
|
-
catch (error) {
|
|
2013
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.SAVE_SSO_CONFIGURATION, value: error.message }));
|
|
2014
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2015
|
-
}
|
|
2016
|
-
finally {
|
|
2017
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_CONFIGURATION, value: false }));
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
function* saveSSOConfigurationByMetadata({ payload }) {
|
|
2021
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_CONFIGURATION_BY_METADATA, value: true }));
|
|
2022
|
-
const { configFile, callback } = payload;
|
|
2023
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2024
|
-
try {
|
|
2025
|
-
const metadata = yield readFileAsText(configFile);
|
|
2026
|
-
const newSsoConfiguration = yield call(api.auth.createSSOConfigurationByMetadata, { metadata });
|
|
2027
|
-
yield put(actions.setSSOState({ ssoConfigurations: [...ssoConfigurations, newSsoConfiguration] }));
|
|
2028
|
-
callback === null || callback === void 0 ? void 0 : callback(newSsoConfiguration);
|
|
2029
|
-
}
|
|
2030
|
-
catch (error) {
|
|
2031
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.SAVE_SSO_CONFIGURATION_BY_METADATA, value: error.message }));
|
|
2032
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2033
|
-
}
|
|
2034
|
-
finally {
|
|
2035
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_CONFIGURATION_BY_METADATA, value: false }));
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
function* updateSSOConfiguration({ payload }) {
|
|
2039
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.UPDATE_SSO_CONFIGURATION, value: true }));
|
|
2040
|
-
const { callback, ssoConfigId } = payload, ssoConfiguration = __rest(payload, ["callback", "ssoConfigId"]);
|
|
2041
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2042
|
-
try {
|
|
2043
|
-
const newSsoConfiguration = yield call(api.auth.updateSSOConfiguration, ssoConfigId, ssoConfiguration);
|
|
2044
|
-
const newSsoConfigurations = ssoConfigurations.map((ssoConfig) => ssoConfig.id === ssoConfigId ? newSsoConfiguration : ssoConfig);
|
|
2045
|
-
yield put(actions.setSSOState({ ssoConfigurations: newSsoConfigurations }));
|
|
2046
|
-
callback === null || callback === void 0 ? void 0 : callback(newSsoConfiguration);
|
|
2047
|
-
}
|
|
2048
|
-
catch (error) {
|
|
2049
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.UPDATE_SSO_CONFIGURATION, value: error.message }));
|
|
2050
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2051
|
-
}
|
|
2052
|
-
finally {
|
|
2053
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.UPDATE_SSO_CONFIGURATION, value: false }));
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
function* updateSSOConfigurationByMetadata({ payload }) {
|
|
2057
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.UPDATE_SSO_CONFIGURATION_BY_METADATA, value: true }));
|
|
2058
|
-
const { callback, ssoConfigId, configFile } = payload;
|
|
2059
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2060
|
-
try {
|
|
2061
|
-
const metadata = yield readFileAsText(configFile);
|
|
2062
|
-
const newSsoConfiguration = yield call(api.auth.updateSSOConfigurationByMetadata, ssoConfigId, { metadata });
|
|
2063
|
-
const newSsoConfigurations = ssoConfigurations.map((ssoConfig) => ssoConfig.id === ssoConfigId ? newSsoConfiguration : ssoConfig);
|
|
2064
|
-
yield put(actions.setSSOState({ ssoConfigurations: newSsoConfigurations }));
|
|
2065
|
-
callback === null || callback === void 0 ? void 0 : callback(newSsoConfiguration);
|
|
2066
|
-
}
|
|
2067
|
-
catch (error) {
|
|
2068
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.UPDATE_SSO_CONFIGURATION, value: error.message }));
|
|
2069
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2070
|
-
}
|
|
2071
|
-
finally {
|
|
2072
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.UPDATE_SSO_CONFIGURATION, value: false }));
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
function* deleteSSOConfiguration({ payload }) {
|
|
2076
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.DELETE_SSO_CONFIGURATION, value: true }));
|
|
2077
|
-
const { ssoConfigId, callback } = payload;
|
|
2078
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2079
|
-
try {
|
|
2080
|
-
yield call(api.auth.deleteSSOConfiguration, ssoConfigId);
|
|
2081
|
-
yield put(actions.setSSOState({ ssoConfigurations: ssoConfigurations.filter(({ id }) => id !== ssoConfigId) }));
|
|
2082
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2083
|
-
}
|
|
2084
|
-
catch (error) {
|
|
2085
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.DELETE_SSO_CONFIGURATION, value: error.message }));
|
|
2086
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2087
|
-
}
|
|
2088
|
-
finally {
|
|
2089
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.DELETE_SSO_CONFIGURATION, value: false }));
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
function* saveSSODomain({ payload }) {
|
|
2093
|
-
const { callback, ssoConfigId } = payload, body = __rest(payload, ["callback", "ssoConfigId"]);
|
|
2094
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_DOMAIN, value: true }));
|
|
2095
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2096
|
-
try {
|
|
2097
|
-
const domain = yield call(api.auth.createSSODomain, ssoConfigId, body);
|
|
2098
|
-
const newSsoConfigurations = ssoConfigurations.map((ssoConfig) => {
|
|
2099
|
-
if (ssoConfig.id === ssoConfigId) {
|
|
2100
|
-
return Object.assign(Object.assign({}, ssoConfig), { domains: [...ssoConfig.domains, domain] });
|
|
2101
|
-
}
|
|
2102
|
-
return ssoConfig;
|
|
2103
|
-
});
|
|
2104
|
-
yield put(actions.setSSOState({ ssoConfigurations: newSsoConfigurations }));
|
|
2105
|
-
callback === null || callback === void 0 ? void 0 : callback(domain);
|
|
2106
|
-
}
|
|
2107
|
-
catch (error) {
|
|
2108
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.SAVE_SSO_DOMAIN, value: error.message }));
|
|
2109
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2110
|
-
}
|
|
2111
|
-
finally {
|
|
2112
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_DOMAIN, value: false }));
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
function* deleteSSODomain({ payload }) {
|
|
2116
|
-
const { ssoConfigId, domainId, callback } = payload;
|
|
2117
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.DELETE_SSO_DOMAIN, value: true }));
|
|
2118
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2119
|
-
try {
|
|
2120
|
-
yield call(api.auth.deleteSSODomain, ssoConfigId, domainId);
|
|
2121
|
-
const newSsoConfigurations = ssoConfigurations.map((ssoConfig) => {
|
|
2122
|
-
if (ssoConfig.id === ssoConfigId) {
|
|
2123
|
-
return Object.assign(Object.assign({}, ssoConfig), { domains: ssoConfig.domains.filter(({ id }) => id !== domainId) });
|
|
2124
|
-
}
|
|
2125
|
-
return ssoConfig;
|
|
2126
|
-
});
|
|
2127
|
-
yield put(actions.setSSOState({ ssoConfigurations: newSsoConfigurations }));
|
|
2128
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2129
|
-
}
|
|
2130
|
-
catch (error) {
|
|
2131
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.DELETE_SSO_DOMAIN, value: error.message }));
|
|
2132
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2133
|
-
}
|
|
2134
|
-
finally {
|
|
2135
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.DELETE_SSO_DOMAIN, value: false }));
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
function* validateSSODomainV2({ payload }) {
|
|
2139
|
-
const { callback, domainId, ssoConfigId } = payload;
|
|
2140
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.VALIDATE_SSO_DOMAIN, value: true }));
|
|
2141
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2142
|
-
try {
|
|
2143
|
-
yield call(api.auth.validateSSODomain, ssoConfigId, domainId);
|
|
2144
|
-
const newSsoConfigurations = ssoConfigurations.map((ssoConfig) => {
|
|
2145
|
-
if (ssoConfig.id === ssoConfigId) {
|
|
2146
|
-
return Object.assign(Object.assign({}, ssoConfig), { domains: ssoConfig.domains.map((ssoDomain) => ssoDomain.id === domainId ? Object.assign(Object.assign({}, ssoDomain), { validated: true }) : ssoDomain) });
|
|
2147
|
-
}
|
|
2148
|
-
return ssoConfig;
|
|
2149
|
-
});
|
|
2150
|
-
yield put(actions.setSSOState({ ssoConfigurations: newSsoConfigurations }));
|
|
2151
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2152
|
-
}
|
|
2153
|
-
catch (error) {
|
|
2154
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.VALIDATE_SSO_DOMAIN, value: error.message }));
|
|
2155
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2156
|
-
}
|
|
2157
|
-
finally {
|
|
2158
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.VALIDATE_SSO_DOMAIN, value: false }));
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
function* setSSODefaultRoles({ payload: { callback, ssoConfigId, roleIds }, }) {
|
|
2162
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.UPDATE_SSO_DEFAULT_ROLES, value: true }));
|
|
2163
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2164
|
-
try {
|
|
2165
|
-
yield call(api.auth.setSSODefaultRoles, ssoConfigId, { roleIds });
|
|
2166
|
-
const newSsoConfigurations = ssoConfigurations.map((ssoConfig) => {
|
|
2167
|
-
if (ssoConfig.id === ssoConfigId) {
|
|
2168
|
-
return Object.assign(Object.assign({}, ssoConfig), { roleIds });
|
|
2169
|
-
}
|
|
2170
|
-
return ssoConfig;
|
|
2171
|
-
});
|
|
2172
|
-
yield put(actions.setSSOState({ ssoConfigurations: newSsoConfigurations }));
|
|
2173
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2174
|
-
}
|
|
2175
|
-
catch (error) {
|
|
2176
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.UPDATE_SSO_DEFAULT_ROLES, value: error.message }));
|
|
2177
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2178
|
-
}
|
|
2179
|
-
finally {
|
|
2180
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.UPDATE_SSO_DEFAULT_ROLES, value: false }));
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
function* setSSOGroups({ payload: { groupsToAdd, groupsToDelete, ssoConfigId, callback } }) {
|
|
2184
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_GROUPS, value: true }));
|
|
2185
|
-
const ssoConfigurations = yield select((state) => state.auth.ssoState.ssoConfigurations);
|
|
2186
|
-
try {
|
|
2187
|
-
yield all(groupsToDelete.map((groupId) => call(api.auth.deleteSSOGroup, ssoConfigId, groupId)));
|
|
2188
|
-
yield all(groupsToAdd.map((group) => call(api.auth.createSSOGroup, ssoConfigId, group)));
|
|
2189
|
-
const groups = yield call(api.auth.getSSOGroups, ssoConfigId);
|
|
2190
|
-
const newSsoConfigurations = ssoConfigurations.map((ssoConfig) => {
|
|
2191
|
-
if (ssoConfig.id === ssoConfigId) {
|
|
2192
|
-
return Object.assign(Object.assign({}, ssoConfig), { groups });
|
|
2193
|
-
}
|
|
2194
|
-
return ssoConfig;
|
|
2195
|
-
});
|
|
2196
|
-
yield put(actions.setSSOState({ ssoConfigurations: newSsoConfigurations }));
|
|
2197
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2198
|
-
}
|
|
2199
|
-
catch (error) {
|
|
2200
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.SAVE_SSO_GROUPS, value: error.message }));
|
|
2201
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2202
|
-
}
|
|
2203
|
-
finally {
|
|
2204
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_GROUPS, value: false }));
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
function* updateSSOGroups({ payload: { ssoConfigId, changedGroups, callback } }) {
|
|
2208
|
-
try {
|
|
2209
|
-
yield all(changedGroups.map((group) => call(api.auth.updateSSOGroup, ssoConfigId, group)));
|
|
2210
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2211
|
-
}
|
|
2212
|
-
catch (error) {
|
|
2213
|
-
yield put(actions.setSSOError({ key: SSOStateKeys.SAVE_SSO_GROUPS, value: error.message }));
|
|
2214
|
-
callback === null || callback === void 0 ? void 0 : callback(null, error);
|
|
2215
|
-
}
|
|
2216
|
-
finally {
|
|
2217
|
-
yield put(actions.setSSOLoader({ key: SSOStateKeys.SAVE_SSO_GROUPS, value: false }));
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
function* ssoSagas() {
|
|
2221
|
-
yield takeEvery(actions.loadSSOConfigurationsV2, loadSSOConfigurationsV2);
|
|
2222
|
-
yield takeEvery(actions.saveSSOConfigurationV2, saveSSOConfigurationV2);
|
|
2223
|
-
yield takeEvery(actions.saveSSODomain, saveSSODomain);
|
|
2224
|
-
yield takeEvery(actions.deleteSSODomain, deleteSSODomain);
|
|
2225
|
-
yield takeEvery(actions.validateSSODomainV2, validateSSODomainV2);
|
|
2226
|
-
yield takeEvery(actions.updateSSOConfiguration, updateSSOConfiguration);
|
|
2227
|
-
yield takeEvery(actions.deleteSSOConfiguration, deleteSSOConfiguration);
|
|
2228
|
-
yield takeEvery(actions.setSSOGroups, setSSOGroups);
|
|
2229
|
-
yield takeEvery(actions.updateSSOGroups, updateSSOGroups);
|
|
2230
|
-
yield takeEvery(actions.setSSODefaultRoles, setSSODefaultRoles);
|
|
2231
|
-
yield takeEvery(actions.saveSSOConfigurationByMetadata, saveSSOConfigurationByMetadata);
|
|
2232
|
-
yield takeEvery(actions.updateSSOConfigurationByMetadata, updateSSOConfigurationByMetadata);
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
function* loadProfile() {
|
|
2236
|
-
yield put(actions.setProfileState({ loading: true }));
|
|
2237
|
-
try {
|
|
2238
|
-
const profile = yield retry(3, 2000, api.teams.getProfile);
|
|
2239
|
-
const currentUser = yield select((state) => state.auth.user);
|
|
2240
|
-
actions.setUser(Object.assign(Object.assign({}, currentUser), profile));
|
|
2241
|
-
yield put(actions.setProfileState({ profile, loading: false }));
|
|
2242
|
-
}
|
|
2243
|
-
catch (e) {
|
|
2244
|
-
yield put(actions.setProfileState({ loading: false, error: e.message }));
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
function b64toBlob(base64, contentType) {
|
|
2248
|
-
const sliceSize = 512;
|
|
2249
|
-
const byteCharacters = atob(base64);
|
|
2250
|
-
const byteArrays = [];
|
|
2251
|
-
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
2252
|
-
const slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
2253
|
-
const byteNumbers = new Array(slice.length);
|
|
2254
|
-
for (let i = 0; i < slice.length; i++) {
|
|
2255
|
-
byteNumbers[i] = slice.charCodeAt(i);
|
|
2256
|
-
}
|
|
2257
|
-
byteArrays.push(new Uint8Array(byteNumbers));
|
|
2258
|
-
}
|
|
2259
|
-
return new Blob(byteArrays, { type: contentType });
|
|
2260
|
-
}
|
|
2261
|
-
function base64ToFormData(base64, key = 'file') {
|
|
2262
|
-
const matchResult = base64.match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);
|
|
2263
|
-
if (matchResult == null) {
|
|
2264
|
-
return null;
|
|
2265
|
-
}
|
|
2266
|
-
// Get the content type of the image
|
|
2267
|
-
const contentType = `image/${matchResult[1]}`;
|
|
2268
|
-
// get the real base64 content of the file
|
|
2269
|
-
const data = matchResult[2];
|
|
2270
|
-
// Convert it to a blob to upload
|
|
2271
|
-
const blob = b64toBlob(data, contentType);
|
|
2272
|
-
// Create a FormData and append the file with "image" as parameter name
|
|
2273
|
-
const formDataToUpload = new FormData();
|
|
2274
|
-
formDataToUpload.append(key, new File([blob], key, { type: contentType }));
|
|
2275
|
-
return formDataToUpload;
|
|
2276
|
-
}
|
|
2277
|
-
function* saveProfile(_a) {
|
|
2278
|
-
var _b = _a.payload, { callback, profilePictureUrl } = _b, payload = __rest(_b, ["callback", "profilePictureUrl"]);
|
|
2279
|
-
yield put(actions.setProfileState({ saving: true, error: null }));
|
|
2280
|
-
try {
|
|
2281
|
-
const oldProfileData = yield select((state) => state.auth.profileState.profile);
|
|
2282
|
-
let newProfilePictureUrl = oldProfileData.profilePictureUrl;
|
|
2283
|
-
if (profilePictureUrl !== oldProfileData.profilePictureUrl && profilePictureUrl) {
|
|
2284
|
-
const matchResult = (profilePictureUrl || '').match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);
|
|
2285
|
-
if (matchResult) {
|
|
2286
|
-
const profileImage = base64ToFormData(profilePictureUrl, 'image');
|
|
2287
|
-
if (profileImage) {
|
|
2288
|
-
newProfilePictureUrl = yield call(api.teams.updateProfileImage, profileImage);
|
|
2289
|
-
const imageTimeStamp = Date.now().toString();
|
|
2290
|
-
const urlTemplate = new URL(newProfilePictureUrl);
|
|
2291
|
-
urlTemplate.searchParams.set('t', imageTimeStamp);
|
|
2292
|
-
newProfilePictureUrl = urlTemplate.href;
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
const newProfileData = Object.assign(Object.assign(Object.assign({}, oldProfileData), payload), { profilePictureUrl: newProfilePictureUrl });
|
|
2297
|
-
const profile = yield call(api.teams.updateProfile, newProfileData);
|
|
2298
|
-
const currentUser = yield select((state) => state.auth.user);
|
|
2299
|
-
yield put(actions.setUser(Object.assign(Object.assign({}, currentUser), profile)));
|
|
2300
|
-
yield put(actions.setProfileState({ profile, saving: false }));
|
|
2301
|
-
callback === null || callback === void 0 ? void 0 : callback(newProfileData);
|
|
2302
|
-
}
|
|
2303
|
-
catch (e) {
|
|
2304
|
-
yield put(actions.setProfileState({ saving: false, error: e.message }));
|
|
2305
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
function* changePassword({ payload }) {
|
|
2309
|
-
var _a, _b;
|
|
2310
|
-
yield put(actions.setProfileState({ loading: true }));
|
|
2311
|
-
try {
|
|
2312
|
-
yield call(api.teams.changePassword, payload);
|
|
2313
|
-
yield put(actions.setProfileState({ loading: false, error: undefined }));
|
|
2314
|
-
(_a = payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, true);
|
|
2315
|
-
}
|
|
2316
|
-
catch (e) {
|
|
2317
|
-
yield put(actions.setProfileState({ loading: false, error: e.message }));
|
|
2318
|
-
(_b = payload.callback) === null || _b === void 0 ? void 0 : _b.call(payload, null, e);
|
|
2319
|
-
}
|
|
2320
|
-
}
|
|
2321
|
-
function* profileSagas() {
|
|
2322
|
-
yield takeLeading(actions.loadProfile, loadProfile);
|
|
2323
|
-
yield takeEvery(actions.saveProfile, saveProfile);
|
|
2324
|
-
yield takeEvery(actions.changePassword, changePassword);
|
|
2325
|
-
}
|
|
2326
|
-
/*********************************
|
|
2327
|
-
* Preview Sagas
|
|
2328
|
-
*********************************/
|
|
2329
|
-
function* loadProfileMock() {
|
|
2330
|
-
yield put(actions.setProfileState({ loading: true }));
|
|
2331
|
-
yield delay();
|
|
2332
|
-
yield put(actions.setUser(Object.assign(Object.assign({}, (userDemo)), userProfileDemo)));
|
|
2333
|
-
yield put(actions.setProfileState({ loading: false, profile: userProfileDemo }));
|
|
2334
|
-
}
|
|
2335
|
-
function* saveProfileMock(_a) {
|
|
2336
|
-
var _b = _a.payload, { callback, profilePictureUrl } = _b, payload = __rest(_b, ["callback", "profilePictureUrl"]);
|
|
2337
|
-
yield put(actions.setProfileState({ saving: true, error: null }));
|
|
2338
|
-
const oldProfileData = profileStateDemo;
|
|
2339
|
-
let newProfilePictureUrl = oldProfileData.profile.profilePictureUrl;
|
|
2340
|
-
if (profilePictureUrl !== oldProfileData.profile.profilePictureUrl && profilePictureUrl) {
|
|
2341
|
-
const matchResult = (profilePictureUrl || '').match(/^data:image\/([A-Za-z-+\/]+);base64,(.+)$/);
|
|
2342
|
-
if (matchResult) {
|
|
2343
|
-
newProfilePictureUrl = profilePictureUrl;
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
const newProfileData = Object.assign(Object.assign(Object.assign({}, oldProfileData.profile), payload), { profilePictureUrl: newProfilePictureUrl });
|
|
2347
|
-
const currentUser = userDemo;
|
|
2348
|
-
yield delay();
|
|
2349
|
-
yield put(actions.setUser(Object.assign(Object.assign({}, currentUser), newProfileData)));
|
|
2350
|
-
yield put(actions.setProfileState({ loading: false, error: null, saving: false, profile: newProfileData }));
|
|
2351
|
-
callback === null || callback === void 0 ? void 0 : callback(newProfileData);
|
|
2352
|
-
}
|
|
2353
|
-
function* changePasswordMock({ payload }) {
|
|
2354
|
-
var _a;
|
|
2355
|
-
yield put(actions.setProfileState({ loading: true }));
|
|
2356
|
-
yield delay();
|
|
2357
|
-
yield put(actions.setProfileState({ loading: false, error: undefined }));
|
|
2358
|
-
(_a = payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, true);
|
|
2359
|
-
}
|
|
2360
|
-
function* profileSagasMock() {
|
|
2361
|
-
yield takeLeading(actions.loadProfile, loadProfileMock);
|
|
2362
|
-
yield takeEvery(actions.saveProfile, saveProfileMock);
|
|
2363
|
-
yield takeEvery(actions.changePassword, changePasswordMock);
|
|
2364
|
-
}
|
|
2365
|
-
|
|
2366
|
-
function* enrollMfa() {
|
|
2367
|
-
yield put(actions.setMfaState({ loading: true }));
|
|
2368
|
-
try {
|
|
2369
|
-
const { qrCode } = yield call(api.auth.enrollMfa);
|
|
2370
|
-
yield put(actions.setMfaState({ loading: false, error: undefined, qrCode }));
|
|
2371
|
-
}
|
|
2372
|
-
catch (e) {
|
|
2373
|
-
yield put(actions.setMfaState({ loading: false, error: e.message }));
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
function* verifyMfa(_a) {
|
|
2377
|
-
var _b = _a.payload, { callback } = _b, payload = __rest(_b, ["callback"]);
|
|
2378
|
-
yield put(actions.setMfaState({ loading: true }));
|
|
2379
|
-
try {
|
|
2380
|
-
const user = yield select((state) => state.auth.user);
|
|
2381
|
-
const data = yield call(api.auth.verifyMfa, payload);
|
|
2382
|
-
const mfaState = {
|
|
2383
|
-
step: MFAStep.recoveryCode,
|
|
2384
|
-
loading: false,
|
|
2385
|
-
error: undefined,
|
|
2386
|
-
};
|
|
2387
|
-
if (data === null || data === void 0 ? void 0 : data.recoveryCode) {
|
|
2388
|
-
mfaState.recoveryCode = data.recoveryCode;
|
|
2389
|
-
}
|
|
2390
|
-
yield put(actions.setMfaState(mfaState));
|
|
2391
|
-
yield put(actions.setUser(Object.assign(Object.assign({}, user), { mfaEnrolled: true })));
|
|
2392
|
-
callback === null || callback === void 0 ? void 0 : callback(mfaState.recoveryCode);
|
|
2393
|
-
}
|
|
2394
|
-
catch (e) {
|
|
2395
|
-
yield put(actions.setMfaState({ loading: false, error: e.message }));
|
|
2396
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
function* verifyMfaAfterForce(_a) {
|
|
2400
|
-
var _b = _a.payload, { callback } = _b, payload = __rest(_b, ["callback"]);
|
|
2401
|
-
yield put(actions.setMfaState({ loading: true }));
|
|
2402
|
-
try {
|
|
2403
|
-
const user = yield call(api.auth.loginWithMfa, payload);
|
|
2404
|
-
const mfaState = {
|
|
2405
|
-
step: MFAStep.recoveryCode,
|
|
2406
|
-
loading: false,
|
|
2407
|
-
error: undefined,
|
|
2408
|
-
};
|
|
2409
|
-
if (user === null || user === void 0 ? void 0 : user.recoveryCode) {
|
|
2410
|
-
mfaState.recoveryCode = user.recoveryCode;
|
|
2411
|
-
}
|
|
2412
|
-
yield put(actions.setMfaState(mfaState));
|
|
2413
|
-
yield put(actions.setState({ user }));
|
|
2414
|
-
yield put(actions.loadTenants());
|
|
2415
|
-
callback === null || callback === void 0 ? void 0 : callback(mfaState.recoveryCode);
|
|
2416
|
-
}
|
|
2417
|
-
catch (e) {
|
|
2418
|
-
yield put(actions.setMfaState({ loading: false, error: e.message }));
|
|
2419
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
function* disableMfa({ payload }) {
|
|
2423
|
-
var _a, _b;
|
|
2424
|
-
yield put(actions.setMfaState({ loading: true }));
|
|
2425
|
-
try {
|
|
2426
|
-
const user = yield select((state) => state.auth.user);
|
|
2427
|
-
yield api.auth.disableMfa(payload);
|
|
2428
|
-
yield put(actions.setMfaState({ loading: false, error: undefined }));
|
|
2429
|
-
yield put(actions.setUser(Object.assign(Object.assign({}, user), { mfaEnrolled: false })));
|
|
2430
|
-
(_a = payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, true);
|
|
2431
|
-
}
|
|
2432
|
-
catch (e) {
|
|
2433
|
-
yield put(actions.setMfaState({ loading: false, error: e.message }));
|
|
2434
|
-
(_b = payload.callback) === null || _b === void 0 ? void 0 : _b.call(payload, false, e);
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
function* mfaSagas() {
|
|
2438
|
-
yield takeEvery(actions.enrollMfa, enrollMfa);
|
|
2439
|
-
yield takeEvery(actions.verifyMfa, verifyMfa);
|
|
2440
|
-
yield takeEvery(actions.disableMfa, disableMfa);
|
|
2441
|
-
yield takeEvery(actions.verifyMfaAfterForce, verifyMfaAfterForce);
|
|
2442
|
-
}
|
|
2443
|
-
/*********************************
|
|
2444
|
-
* Preview Sagas
|
|
2445
|
-
*********************************/
|
|
2446
|
-
function* enrollMfaMock() {
|
|
2447
|
-
yield put(actions.setMfaState({ loading: true }));
|
|
2448
|
-
const qrCode = 'test';
|
|
2449
|
-
yield put(actions.setMfaState({ loading: false, error: undefined, qrCode }));
|
|
2450
|
-
}
|
|
2451
|
-
function* verifyMfaMock({ payload: { callback }, }) {
|
|
2452
|
-
yield put(actions.setMfaState({ loading: true }));
|
|
2453
|
-
yield delay();
|
|
2454
|
-
const data = { token: 'token', recoveryCode: 'recoveryCode' };
|
|
2455
|
-
const mfaState = {
|
|
2456
|
-
step: MFAStep.recoveryCode,
|
|
2457
|
-
loading: false,
|
|
2458
|
-
error: undefined,
|
|
2459
|
-
};
|
|
2460
|
-
if (data === null || data === void 0 ? void 0 : data.recoveryCode) {
|
|
2461
|
-
mfaState.recoveryCode = data.recoveryCode;
|
|
2462
|
-
}
|
|
2463
|
-
yield put(actions.setMfaState(mfaState));
|
|
2464
|
-
yield put(actions.setUser(Object.assign(Object.assign({}, userDemo), { mfaEnrolled: true })));
|
|
2465
|
-
callback === null || callback === void 0 ? void 0 : callback(mfaState.recoveryCode);
|
|
2466
|
-
}
|
|
2467
|
-
function* verifyMfaAfterForceMock(_a) {
|
|
2468
|
-
var _b = _a.payload, { callback } = _b, payload = __rest(_b, ["callback"]);
|
|
2469
|
-
yield put(actions.setMfaState({ loading: true }));
|
|
2470
|
-
yield delay();
|
|
2471
|
-
const data = Object.assign(Object.assign({}, payload), { recoveryCode: 'recoveryCode' });
|
|
2472
|
-
const mfaState = {
|
|
2473
|
-
step: MFAStep.recoveryCode,
|
|
2474
|
-
loading: false,
|
|
2475
|
-
error: undefined,
|
|
2476
|
-
};
|
|
2477
|
-
if (data === null || data === void 0 ? void 0 : data.recoveryCode) {
|
|
2478
|
-
mfaState.recoveryCode = data.recoveryCode;
|
|
2479
|
-
}
|
|
2480
|
-
yield put(actions.setMfaState(mfaState));
|
|
2481
|
-
yield delay();
|
|
2482
|
-
yield put(actions.setUser(Object.assign(Object.assign({}, userDemo), { mfaEnrolled: true })));
|
|
2483
|
-
callback === null || callback === void 0 ? void 0 : callback(mfaState.recoveryCode);
|
|
2484
|
-
}
|
|
2485
|
-
function* disableMfaMock({ payload }) {
|
|
2486
|
-
var _a;
|
|
2487
|
-
yield put(actions.setMfaState({ loading: true }));
|
|
2488
|
-
yield delay();
|
|
2489
|
-
yield put(actions.setMfaState({ loading: false, error: undefined }));
|
|
2490
|
-
yield put(actions.setUser(Object.assign(Object.assign({}, userDemo), { mfaEnrolled: false })));
|
|
2491
|
-
(_a = payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, true);
|
|
2492
|
-
}
|
|
2493
|
-
function* mfaSagasMock() {
|
|
2494
|
-
yield takeEvery(actions.enrollMfa, enrollMfaMock);
|
|
2495
|
-
yield takeEvery(actions.verifyMfa, verifyMfaMock);
|
|
2496
|
-
yield takeEvery(actions.disableMfa, disableMfaMock);
|
|
2497
|
-
yield takeEvery(actions.verifyMfaAfterForce, verifyMfaAfterForceMock);
|
|
2498
|
-
}
|
|
2499
|
-
|
|
2500
|
-
function* forgotPassword({ payload }) {
|
|
2501
|
-
yield put(actions.setForgotPasswordState({ loading: true }));
|
|
2502
|
-
try {
|
|
2503
|
-
yield call(api.auth.forgotPassword, payload);
|
|
2504
|
-
yield put(actions.setForgotPasswordState({ loading: false, error: undefined, step: ForgotPasswordStep.success }));
|
|
2505
|
-
}
|
|
2506
|
-
catch (e) {
|
|
2507
|
-
yield put(actions.setForgotPasswordState({ loading: false, error: e.message || 'Unknown error occurred' }));
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
function* resetPassword(_a) {
|
|
2511
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
2512
|
-
yield put(actions.setForgotPasswordState({ loading: true }));
|
|
2513
|
-
try {
|
|
2514
|
-
yield call(api.auth.resetPassword, body);
|
|
2515
|
-
yield put(actions.setForgotPasswordState({ loading: false, error: undefined, step: ForgotPasswordStep.success }));
|
|
2516
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2517
|
-
}
|
|
2518
|
-
catch (e) {
|
|
2519
|
-
yield put(actions.setForgotPasswordState({ loading: false, error: e.message }));
|
|
2520
|
-
callback === null || callback === void 0 ? void 0 : callback(false);
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
function* loadPasswordConfig({ payload }) {
|
|
2524
|
-
yield put(actions.setForgotPasswordState({ loading: true }));
|
|
2525
|
-
try {
|
|
2526
|
-
const passwordConfig = yield call(api.auth.loadPasswordConfig, payload);
|
|
2527
|
-
yield put(actions.setForgotPasswordState({ loading: false, passwordConfig }));
|
|
2528
|
-
}
|
|
2529
|
-
catch (e) {
|
|
2530
|
-
yield put(actions.setForgotPasswordState({ loading: false, error: e.message }));
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
function* forgotPasswordSagas() {
|
|
2534
|
-
yield takeLeading(actions.forgotPassword, forgotPassword);
|
|
2535
|
-
yield takeLeading(actions.resetPassword, resetPassword);
|
|
2536
|
-
yield takeLeading(actions.loadPasswordConfig, loadPasswordConfig);
|
|
2537
|
-
}
|
|
2538
|
-
|
|
2539
|
-
function* preActivateAccount({ payload: { userId, token } }) {
|
|
2540
|
-
yield put(actions.setActivateState({ loading: true, step: ActivateAccountStep.activating }));
|
|
2541
|
-
try {
|
|
2542
|
-
const { isAuthenticated } = yield select((state) => state.auth);
|
|
2543
|
-
if (isAuthenticated) {
|
|
2544
|
-
yield put(actions.silentLogout());
|
|
2545
|
-
}
|
|
2546
|
-
const strategy = yield call(api.auth.getActivateAccountStrategy, { userId, token });
|
|
2547
|
-
yield put(actions.setActivateStrategyState({ strategy, loading: false, error: undefined }));
|
|
2548
|
-
if (strategy.shouldSetPassword) {
|
|
2549
|
-
yield put(actions.setActivateState({ loading: false, step: ActivateAccountStep.activatingForm }));
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
catch (e) {
|
|
2553
|
-
yield put(actions.setActivateState({ loading: false, error: e.message }));
|
|
2554
|
-
}
|
|
2555
|
-
}
|
|
2556
|
-
function* activateAccount(_a) {
|
|
2557
|
-
var _b;
|
|
2558
|
-
var _c = _a.payload, { callback, events } = _c, payload = __rest(_c, ["callback", "events"]);
|
|
2559
|
-
yield put(actions.setActivateState({ loading: true }));
|
|
2560
|
-
try {
|
|
2561
|
-
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
2562
|
-
const { routes } = yield select((state) => state.auth);
|
|
2563
|
-
const data = yield call(api.auth.activateAccount, payload);
|
|
2564
|
-
if (data.redirectLocation) {
|
|
2565
|
-
window.location.href = data.redirectLocation;
|
|
2566
|
-
return;
|
|
2567
|
-
}
|
|
2568
|
-
if (isMfaRequired(data)) {
|
|
2569
|
-
yield put(actions.setActivateState({ step: ActivateAccountStep.success }));
|
|
2570
|
-
const mfaRequiredState = yield getMfaRequiredState(data);
|
|
2571
|
-
yield put(actions.setState(mfaRequiredState));
|
|
2572
|
-
yield delay$1(1000);
|
|
2573
|
-
onRedirectTo(routes.loginUrl, { preserveQueryParams: true });
|
|
2574
|
-
}
|
|
2575
|
-
else {
|
|
2576
|
-
yield put(actions.setActivateState({ step: ActivateAccountStep.success }));
|
|
2577
|
-
const { user, tenants } = yield call(api.auth.generateLoginResponseV2, data);
|
|
2578
|
-
(_b = events === null || events === void 0 ? void 0 : events.userVerified) === null || _b === void 0 ? void 0 : _b.call(events, { email: user.email, origin: UserVeirifedOriginTypes.ACTIVATION_LINK, id: user.id, tenantId: user.tenantId, name: user.name, createdAt: new Date() });
|
|
2579
|
-
yield put(actions.setTenantsState({ tenants, loading: false }));
|
|
2580
|
-
yield put(actions.setState({ user, isAuthenticated: true }));
|
|
2581
|
-
yield delay$1(1000);
|
|
2582
|
-
yield afterAuthNavigation();
|
|
2583
|
-
yield put(actions.resetActivateState());
|
|
2584
|
-
}
|
|
2585
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2586
|
-
}
|
|
2587
|
-
catch (e) {
|
|
2588
|
-
yield put(actions.setActivateState({ loading: false, error: e.message }));
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
function* getActivateAccountStrategy({ payload, }) {
|
|
2592
|
-
const { callback } = payload, params = __rest(payload, ["callback"]);
|
|
2593
|
-
yield put(actions.setActivateStrategyState({ loading: true }));
|
|
2594
|
-
try {
|
|
2595
|
-
const strategy = yield call(api.auth.getActivateAccountStrategy, params);
|
|
2596
|
-
yield put(actions.setActivateStrategyState({ strategy, loading: false, error: undefined }));
|
|
2597
|
-
callback === null || callback === void 0 ? void 0 : callback(strategy);
|
|
2598
|
-
}
|
|
2599
|
-
catch (e) {
|
|
2600
|
-
yield put(actions.setActivateStrategyState({ loading: false, error: e.message }));
|
|
2601
|
-
}
|
|
2602
|
-
}
|
|
2603
|
-
function* resendActivationEmailFunction({ payload }) {
|
|
2604
|
-
yield put(actions.setActivateState({ loading: true }));
|
|
2605
|
-
try {
|
|
2606
|
-
yield call(api.auth.resendActivationEmail, { email: payload.email });
|
|
2607
|
-
yield put(actions.setActivateState({ loading: false, error: undefined, resentEmail: true }));
|
|
2608
|
-
}
|
|
2609
|
-
catch (e) {
|
|
2610
|
-
yield put(actions.setActivateState({ loading: false, error: e.message }));
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
function* activateSagas() {
|
|
2614
|
-
yield takeLeading(actions.activateAccount, activateAccount);
|
|
2615
|
-
yield takeLeading(actions.preActivateAccount, preActivateAccount);
|
|
2616
|
-
yield takeLeading(actions.getActivateAccountStrategy, getActivateAccountStrategy);
|
|
2617
|
-
yield takeLeading(actions.resendActivationEmail, resendActivationEmailFunction);
|
|
2618
|
-
}
|
|
2619
|
-
|
|
2620
|
-
function* acceptInvitation({ payload }) {
|
|
2621
|
-
if (!payload.token || !payload.userId) {
|
|
2622
|
-
yield put(actions.setAcceptInvitationState({ error: undefined, step: AcceptInvitationStep.invalid }));
|
|
2623
|
-
return;
|
|
2624
|
-
}
|
|
2625
|
-
try {
|
|
2626
|
-
yield put(actions.setAcceptInvitationState({ error: undefined, step: AcceptInvitationStep.pending }));
|
|
2627
|
-
yield call(api.auth.acceptInvitation, payload);
|
|
2628
|
-
yield put(actions.setState({
|
|
2629
|
-
isAuthenticated: false,
|
|
2630
|
-
user: null,
|
|
2631
|
-
acceptInvitationState: { error: undefined, step: AcceptInvitationStep.success },
|
|
2632
|
-
}));
|
|
2633
|
-
}
|
|
2634
|
-
catch (e) {
|
|
2635
|
-
yield put(actions.setAcceptInvitationState({ step: AcceptInvitationStep.failed, error: e.message }));
|
|
2636
|
-
}
|
|
2637
|
-
}
|
|
2638
|
-
function* acceptInvitationSagas() {
|
|
2639
|
-
yield takeLeading(actions.acceptInvitation, acceptInvitation);
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
var TeamStateKeys;
|
|
2643
|
-
(function (TeamStateKeys) {
|
|
2644
|
-
TeamStateKeys["USERS"] = "USERS";
|
|
2645
|
-
TeamStateKeys["STATS"] = "STATS";
|
|
2646
|
-
TeamStateKeys["UPDATE_USER"] = "UPDATE_USER";
|
|
2647
|
-
TeamStateKeys["DELETE_USER"] = "DELETE_USER";
|
|
2648
|
-
TeamStateKeys["RESEND_ACTIVATE_LINK"] = "RESEND_ACTIVATE_LINK";
|
|
2649
|
-
TeamStateKeys["RESEND_INVITATION_LINK"] = "RESEND_INVITATION_LINK";
|
|
2650
|
-
TeamStateKeys["ROLES_AND_PERMISSIONS"] = "ROLES_AND_PERMISSIONS";
|
|
2651
|
-
TeamStateKeys["CREATE_TOKEN_LINK"] = "CREATE_TOKEN_LINK";
|
|
2652
|
-
TeamStateKeys["GET_TOKEN_LINK"] = "GET_TOKEN_LINK";
|
|
2653
|
-
TeamStateKeys["UPDATE_TOKEN_LINK"] = "UPDATE_TOKEN_LINK";
|
|
2654
|
-
TeamStateKeys["DELETE_TOKEN_LINK"] = "DELETE_TOKEN_LINK";
|
|
2655
|
-
TeamStateKeys["CONFIG_TOKEN_LINK"] = "CONFIG_TOKEN_LINK";
|
|
2656
|
-
})(TeamStateKeys || (TeamStateKeys = {}));
|
|
2657
|
-
|
|
2658
|
-
const selectTeamState = () => select((_) => _[authStoreName].teamState);
|
|
2659
|
-
function* loadUsers({ payload }) {
|
|
2660
|
-
var _a, _b, _c, _d;
|
|
2661
|
-
const { silentLoading, callback } = payload;
|
|
2662
|
-
const teamState = yield selectTeamState();
|
|
2663
|
-
const pageSize = (_a = payload.pageSize) !== null && _a !== void 0 ? _a : teamState.pageSize;
|
|
2664
|
-
const pageOffset = (_b = payload.pageOffset) !== null && _b !== void 0 ? _b : teamState.pageOffset;
|
|
2665
|
-
const filter = (_c = payload.filter) !== null && _c !== void 0 ? _c : teamState.filter;
|
|
2666
|
-
const sort = (_d = payload.sort) !== null && _d !== void 0 ? _d : teamState.sort;
|
|
2667
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.USERS, value: !silentLoading }));
|
|
2668
|
-
yield put(actions.setTeamState({
|
|
2669
|
-
pageSize,
|
|
2670
|
-
pageOffset,
|
|
2671
|
-
filter,
|
|
2672
|
-
sort,
|
|
2673
|
-
}));
|
|
2674
|
-
try {
|
|
2675
|
-
const [{ items: users, totalPages, totalItems }, { items: roles }, { items: permissions }] = yield all([
|
|
2676
|
-
call(api.teams.loadUsers, {
|
|
2677
|
-
pageSize,
|
|
2678
|
-
pageOffset,
|
|
2679
|
-
filter,
|
|
2680
|
-
sort,
|
|
2681
|
-
}),
|
|
2682
|
-
call(api.teams.loadAvailableRoles),
|
|
2683
|
-
call(api.teams.loadAvailablePermissions),
|
|
2684
|
-
]);
|
|
2685
|
-
yield put(actions.setTeamState({ users, totalPages, totalItems, roles, permissions }));
|
|
2686
|
-
callback === null || callback === void 0 ? void 0 : callback(users);
|
|
2687
|
-
}
|
|
2688
|
-
catch (e) {
|
|
2689
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.USERS, value: e.message }));
|
|
2690
|
-
yield put(actions.setTeamState({ totalPages: 0, users: [] }));
|
|
2691
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
2692
|
-
}
|
|
2693
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.USERS, value: false }));
|
|
2694
|
-
}
|
|
2695
|
-
function* loadAllSubTenantsUsers({ payload, }) {
|
|
2696
|
-
var _a, _b, _c, _d, _e;
|
|
2697
|
-
const { silentLoading, callback } = payload;
|
|
2698
|
-
const teamState = yield selectTeamState();
|
|
2699
|
-
const _limit = (_a = payload._limit) !== null && _a !== void 0 ? _a : teamState.allUsersQueryParams._limit;
|
|
2700
|
-
const _offset = (_b = payload._offset) !== null && _b !== void 0 ? _b : teamState.allUsersQueryParams._offset;
|
|
2701
|
-
const _filter = (_c = payload._filter) !== null && _c !== void 0 ? _c : teamState.allUsersQueryParams._filter;
|
|
2702
|
-
const _sortBy = (_d = payload._sortBy) !== null && _d !== void 0 ? _d : teamState.allUsersQueryParams._sortBy;
|
|
2703
|
-
const _order = (_e = payload._order) !== null && _e !== void 0 ? _e : teamState.allUsersQueryParams._order;
|
|
2704
|
-
const allUsersQueryParams = {
|
|
2705
|
-
_limit: _limit || 20,
|
|
2706
|
-
_offset: _offset || 0,
|
|
2707
|
-
_filter: _filter || '',
|
|
2708
|
-
_sortBy: _sortBy || 'name',
|
|
2709
|
-
_order: _order || 'DESC',
|
|
2710
|
-
};
|
|
2711
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.USERS, value: !silentLoading }));
|
|
2712
|
-
yield put(actions.setTeamState({
|
|
2713
|
-
allUsersQueryParams,
|
|
2714
|
-
}));
|
|
2715
|
-
try {
|
|
2716
|
-
const [{ items: users, _metadata: { totalPages, totalItems }, }, { items: roles }, { items: permissions },] = yield all([
|
|
2717
|
-
call(api.subTenants.loadAllUsers, Object.assign({}, allUsersQueryParams)),
|
|
2718
|
-
call(api.teams.loadAvailableRoles),
|
|
2719
|
-
call(api.teams.loadAvailablePermissions),
|
|
2720
|
-
]);
|
|
2721
|
-
yield put(actions.setTeamState({
|
|
2722
|
-
allUsers: users,
|
|
2723
|
-
totalPages,
|
|
2724
|
-
totalItems,
|
|
2725
|
-
roles,
|
|
2726
|
-
permissions,
|
|
2727
|
-
}));
|
|
2728
|
-
callback === null || callback === void 0 ? void 0 : callback(users);
|
|
2729
|
-
}
|
|
2730
|
-
catch (e) {
|
|
2731
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.USERS, value: e.message }));
|
|
2732
|
-
yield put(actions.setTeamState({ totalPages: 0, users: [] }));
|
|
2733
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
2734
|
-
}
|
|
2735
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.USERS, value: false }));
|
|
2736
|
-
}
|
|
2737
|
-
function* loadRoles({ payload }) {
|
|
2738
|
-
var _a, _b;
|
|
2739
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.ROLES_AND_PERMISSIONS, value: true }));
|
|
2740
|
-
try {
|
|
2741
|
-
const [{ items: roles }, { items: permissions }] = yield all([
|
|
2742
|
-
call(api.teams.loadAvailableRoles),
|
|
2743
|
-
call(api.teams.loadAvailablePermissions),
|
|
2744
|
-
]);
|
|
2745
|
-
yield put(actions.setTeamState({ roles, permissions }));
|
|
2746
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, { roles, permissions });
|
|
2747
|
-
}
|
|
2748
|
-
catch (e) {
|
|
2749
|
-
(_b = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _b === void 0 ? void 0 : _b.call(payload, null, e);
|
|
2750
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.ROLES_AND_PERMISSIONS, value: e.message }));
|
|
2751
|
-
}
|
|
2752
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.ROLES_AND_PERMISSIONS, value: true }));
|
|
2753
|
-
}
|
|
2754
|
-
function* addUser({ payload }) {
|
|
2755
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
2756
|
-
const teamState = yield selectTeamState();
|
|
2757
|
-
yield put(actions.setTeamState({ addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }) }));
|
|
2758
|
-
try {
|
|
2759
|
-
const res = yield call(api.teams.addUser, body);
|
|
2760
|
-
const { roles } = res, userWithoutRoleIds = __rest(res, ["roles"]);
|
|
2761
|
-
const roleIds = roles.map((role) => role.id);
|
|
2762
|
-
const newUser = Object.assign(Object.assign({}, userWithoutRoleIds), { roleIds });
|
|
2763
|
-
callback === null || callback === void 0 ? void 0 : callback(newUser);
|
|
2764
|
-
yield put(actions.setTeamState({
|
|
2765
|
-
users: [newUser, ...teamState.users],
|
|
2766
|
-
addUserDialogState: { open: false, loading: false },
|
|
2767
|
-
}));
|
|
2768
|
-
}
|
|
2769
|
-
catch (e) {
|
|
2770
|
-
yield put(actions.setTeamState({
|
|
2771
|
-
addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: false, error: e.message }),
|
|
2772
|
-
}));
|
|
2773
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2776
|
-
function* addUserToSubTenants({ payload }) {
|
|
2777
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
2778
|
-
const teamState = yield selectTeamState();
|
|
2779
|
-
yield put(actions.setTeamState({ addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }) }));
|
|
2780
|
-
try {
|
|
2781
|
-
yield call(api.subTenants.addUserToTenantAndSubTenants, body);
|
|
2782
|
-
const { items: users, _metadata: { totalPages, totalItems }, } = yield call(api.subTenants.loadAllUsers, {
|
|
2783
|
-
_limit: 20,
|
|
2784
|
-
_offset: 0,
|
|
2785
|
-
_filter: '',
|
|
2786
|
-
_sortBy: 'name',
|
|
2787
|
-
_order: 'DESC',
|
|
2788
|
-
});
|
|
2789
|
-
yield put(actions.setTeamState({
|
|
2790
|
-
allUsers: users,
|
|
2791
|
-
totalPages,
|
|
2792
|
-
totalItems,
|
|
2793
|
-
addUserDialogState: { open: false, loading: false },
|
|
2794
|
-
}));
|
|
2795
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
2796
|
-
}
|
|
2797
|
-
catch (e) {
|
|
2798
|
-
yield put(actions.setTeamState({
|
|
2799
|
-
addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: false, error: e.message }),
|
|
2800
|
-
}));
|
|
2801
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
function* updateUser({ payload }) {
|
|
2805
|
-
var _a;
|
|
2806
|
-
const { callback, profileImage } = payload, body = __rest(payload, ["callback", "profileImage"]);
|
|
2807
|
-
const { id: userId } = body;
|
|
2808
|
-
const teamState = yield selectTeamState();
|
|
2809
|
-
const oldUserData = teamState.users.find((user) => user.id === body.id);
|
|
2810
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.UPDATE_USER, value: userId || '' }));
|
|
2811
|
-
yield put(actions.setTeamState({ addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }) }));
|
|
2812
|
-
yield put(actions.setTeamState({
|
|
2813
|
-
addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }),
|
|
2814
|
-
users: teamState.users.map((user) => {
|
|
2815
|
-
if (user.id === body.id) {
|
|
2816
|
-
return Object.assign(Object.assign({}, user), body);
|
|
2817
|
-
}
|
|
2818
|
-
return user;
|
|
2819
|
-
}),
|
|
2820
|
-
}));
|
|
2821
|
-
try {
|
|
2822
|
-
if (oldUserData.roleIds.length > 0 && ((_a = body.roleIds) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
2823
|
-
body.roleIds = [''];
|
|
2824
|
-
}
|
|
2825
|
-
const { item: newUser } = yield call(api.teams.updateUser, body);
|
|
2826
|
-
callback === null || callback === void 0 ? void 0 : callback(newUser);
|
|
2827
|
-
yield put(actions.setTeamState({
|
|
2828
|
-
users: teamState.users.map((user) => user.id === newUser.id
|
|
2829
|
-
? Object.assign(Object.assign(Object.assign({}, user), newUser), { createdAt: user.createdAt, customData: user.customData, lastLogin: user.lastLogin }) : user),
|
|
2830
|
-
}));
|
|
2831
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.UPDATE_USER, value: false }));
|
|
2832
|
-
}
|
|
2833
|
-
catch (e) {
|
|
2834
|
-
yield put(actions.setTeamState({
|
|
2835
|
-
addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: false, error: e.message }),
|
|
2836
|
-
users: teamState.users.map((user) => (user.id === body.id ? Object.assign(Object.assign({}, user), oldUserData) : user)),
|
|
2837
|
-
}));
|
|
2838
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.UPDATE_USER, value: false }));
|
|
2839
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2840
|
-
}
|
|
2841
|
-
}
|
|
2842
|
-
function* deleteUser({ payload }) {
|
|
2843
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
2844
|
-
const teamState = yield selectTeamState();
|
|
2845
|
-
yield put(actions.setTeamState({ deleteUserDialogState: Object.assign(Object.assign({}, teamState.deleteUserDialogState), { loading: true }) }));
|
|
2846
|
-
try {
|
|
2847
|
-
yield call(api.teams.deleteUser, body);
|
|
2848
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2849
|
-
yield put(actions.setTeamState({
|
|
2850
|
-
users: teamState.users.filter((user) => user.id !== body.userId),
|
|
2851
|
-
deleteUserDialogState: { open: false, loading: false },
|
|
2852
|
-
}));
|
|
2853
|
-
}
|
|
2854
|
-
catch (e) {
|
|
2855
|
-
yield put(actions.setTeamState({
|
|
2856
|
-
deleteUserDialogState: Object.assign(Object.assign({}, teamState.deleteUserDialogState), { loading: false, error: e.message }),
|
|
2857
|
-
}));
|
|
2858
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2859
|
-
}
|
|
2860
|
-
}
|
|
2861
|
-
function* setUserRolesForSubTenants({ payload, }) {
|
|
2862
|
-
const { callback, userId } = payload, body = __rest(payload, ["callback", "userId"]);
|
|
2863
|
-
const teamState = yield selectTeamState();
|
|
2864
|
-
yield put(actions.setTeamState({ addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }) }));
|
|
2865
|
-
try {
|
|
2866
|
-
yield call(api.subTenants.setUserRolesForSubTenants, userId, body);
|
|
2867
|
-
const updatedUser = teamState.allUsers.find((user) => user.id === userId);
|
|
2868
|
-
if (updatedUser) {
|
|
2869
|
-
updatedUser.tenants = updatedUser.tenants.map((tenant) => {
|
|
2870
|
-
var _a;
|
|
2871
|
-
return (Object.assign(Object.assign({}, tenant), { roles: ((_a = body.subTenantsRoles
|
|
2872
|
-
.find((roleUpdate) => roleUpdate.tenantId === tenant.tenantId)) === null || _a === void 0 ? void 0 : _a.roleIds.map((roleId) => {
|
|
2873
|
-
const role = teamState.roles.find(({ id }) => roleId === id);
|
|
2874
|
-
return role;
|
|
2875
|
-
}).filter((role) => role)) || tenant.roles }));
|
|
2876
|
-
});
|
|
2877
|
-
}
|
|
2878
|
-
yield put(actions.setTeamState({
|
|
2879
|
-
allUsers: [
|
|
2880
|
-
...teamState.allUsers.filter((user) => user.id !== userId),
|
|
2881
|
-
...(updatedUser ? [updatedUser] : []),
|
|
2882
|
-
],
|
|
2883
|
-
addUserDialogState: { open: false, loading: false },
|
|
2884
|
-
}));
|
|
2885
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2886
|
-
}
|
|
2887
|
-
catch (e) {
|
|
2888
|
-
yield put(actions.setTeamState({
|
|
2889
|
-
addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: false, error: e.message }),
|
|
2890
|
-
}));
|
|
2891
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
function* deleteUserFromSubTenants({ payload }) {
|
|
2895
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
2896
|
-
const teamState = yield selectTeamState();
|
|
2897
|
-
yield put(actions.setTeamState({ deleteUserDialogState: Object.assign(Object.assign({}, teamState.deleteUserDialogState), { loading: true }) }));
|
|
2898
|
-
try {
|
|
2899
|
-
yield call(api.subTenants.removeUserFromTenantAndSubTenants, body);
|
|
2900
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2901
|
-
yield put(actions.setTeamState({
|
|
2902
|
-
allUsers: teamState.allUsers.filter((user) => user.id !== body.userId && user.tenants.length === body.subTenants.length),
|
|
2903
|
-
deleteUserDialogState: { open: false, loading: false },
|
|
2904
|
-
}));
|
|
2905
|
-
}
|
|
2906
|
-
catch (e) {
|
|
2907
|
-
yield put(actions.setTeamState({
|
|
2908
|
-
deleteUserDialogState: Object.assign(Object.assign({}, teamState.deleteUserDialogState), { loading: false, error: e.message }),
|
|
2909
|
-
}));
|
|
2910
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2911
|
-
}
|
|
2912
|
-
}
|
|
2913
|
-
function* resendActivationLink({ payload }) {
|
|
2914
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
2915
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.RESEND_ACTIVATE_LINK, value: body.userId }));
|
|
2916
|
-
try {
|
|
2917
|
-
yield call(api.teams.resendActivationLink, body);
|
|
2918
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2919
|
-
}
|
|
2920
|
-
catch (e) {
|
|
2921
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.RESEND_ACTIVATE_LINK, value: e.message }));
|
|
2922
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2923
|
-
}
|
|
2924
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.RESEND_ACTIVATE_LINK, value: false }));
|
|
2925
|
-
}
|
|
2926
|
-
function* resendInvitationLink({ payload }) {
|
|
2927
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
2928
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.RESEND_INVITATION_LINK, value: body.email }));
|
|
2929
|
-
try {
|
|
2930
|
-
yield call(api.teams.resendInvitationLink, body);
|
|
2931
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2932
|
-
}
|
|
2933
|
-
catch (e) {
|
|
2934
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.RESEND_INVITATION_LINK, value: e.message }));
|
|
2935
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2936
|
-
}
|
|
2937
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.RESEND_INVITATION_LINK, value: false }));
|
|
2938
|
-
}
|
|
2939
|
-
function* getInvitationLinkConfig() {
|
|
2940
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.CONFIG_TOKEN_LINK, value: false }));
|
|
2941
|
-
try {
|
|
2942
|
-
const invitationLinkConfig = yield call(api.teams.getInviteLinkConfiguration);
|
|
2943
|
-
yield put(actions.setTeamState({ inviteTokenState: Object.assign({}, invitationLinkConfig) }));
|
|
2944
|
-
}
|
|
2945
|
-
catch (e) {
|
|
2946
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.CONFIG_TOKEN_LINK, value: e.message }));
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
function* getInvitationLink() {
|
|
2950
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.GET_TOKEN_LINK, value: false }));
|
|
2951
|
-
try {
|
|
2952
|
-
yield call(getInvitationLinkConfig);
|
|
2953
|
-
const data = yield call(api.teams.getInviteUserLink);
|
|
2954
|
-
const { inviteTokenState } = yield selectTeamState();
|
|
2955
|
-
yield put(actions.setTeamState({ inviteTokenState: Object.assign(Object.assign({}, inviteTokenState), data) }));
|
|
2956
|
-
}
|
|
2957
|
-
catch (e) {
|
|
2958
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.GET_TOKEN_LINK, value: e.message }));
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
function* createInvitationLink({ payload: { callback }, }) {
|
|
2962
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.CREATE_TOKEN_LINK, value: false }));
|
|
2963
|
-
const { inviteTokenState } = yield selectTeamState();
|
|
2964
|
-
try {
|
|
2965
|
-
const data = yield call(api.teams.createInviteUserLink, { expiresInMinutes: 43200 });
|
|
2966
|
-
yield put(actions.setTeamState({ inviteTokenState: Object.assign(Object.assign({}, inviteTokenState), data) }));
|
|
2967
|
-
callback === null || callback === void 0 ? void 0 : callback(data.token);
|
|
2968
|
-
}
|
|
2969
|
-
catch (e) {
|
|
2970
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2971
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.CREATE_TOKEN_LINK, value: e.message }));
|
|
2972
|
-
}
|
|
2973
|
-
}
|
|
2974
|
-
function* updateInvitationLink({ payload: { callback, expiresInMinutes, shouldSendEmail }, }) {
|
|
2975
|
-
const { inviteTokenState } = yield selectTeamState();
|
|
2976
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.UPDATE_TOKEN_LINK, value: false }));
|
|
2977
|
-
try {
|
|
2978
|
-
const data = yield call(api.teams.updateInviteUserLink, { expiresInMinutes, shouldSendEmail });
|
|
2979
|
-
yield put(actions.setTeamState({ inviteTokenState: Object.assign(Object.assign({}, inviteTokenState), data) }));
|
|
2980
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2981
|
-
}
|
|
2982
|
-
catch (e) {
|
|
2983
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
2984
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.UPDATE_TOKEN_LINK, value: e.message }));
|
|
2985
|
-
}
|
|
2986
|
-
}
|
|
2987
|
-
function* deleteInvitationLink({ payload }) {
|
|
2988
|
-
const { callback } = payload !== null && payload !== void 0 ? payload : {};
|
|
2989
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.DELETE_TOKEN_LINK, value: false }));
|
|
2990
|
-
try {
|
|
2991
|
-
yield call(api.teams.deleteInviteUserLink);
|
|
2992
|
-
yield put(actions.setTeamState({ inviteTokenState: undefined }));
|
|
2993
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
2994
|
-
}
|
|
2995
|
-
catch (e) {
|
|
2996
|
-
yield put(actions.setTeamError({ key: TeamStateKeys.DELETE_TOKEN_LINK, value: e.message }));
|
|
2997
|
-
callback === null || callback === void 0 ? void 0 : callback(false, e.message);
|
|
2998
|
-
}
|
|
2999
|
-
}
|
|
3000
|
-
function* openAddUserDialog({ payload }) {
|
|
3001
|
-
yield put(actions.setTeamState({
|
|
3002
|
-
addUserDialogState: Object.assign({ open: true, loading: false, error: false }, payload),
|
|
3003
|
-
}));
|
|
3004
|
-
}
|
|
3005
|
-
function* closeAddUserDialog({ payload }) {
|
|
3006
|
-
const teamState = yield selectTeamState();
|
|
3007
|
-
const { addUserDialogState: { onClose }, } = teamState;
|
|
3008
|
-
onClose === null || onClose === void 0 ? void 0 : onClose(payload);
|
|
3009
|
-
yield put(actions.setTeamState({
|
|
3010
|
-
addUserDialogState: {
|
|
3011
|
-
loading: false,
|
|
3012
|
-
error: false,
|
|
3013
|
-
open: false,
|
|
3014
|
-
},
|
|
3015
|
-
}));
|
|
3016
|
-
}
|
|
3017
|
-
function* openDeleteUserDialog({ payload }) {
|
|
3018
|
-
yield put(actions.setTeamState({
|
|
3019
|
-
deleteUserDialogState: Object.assign({ open: true, loading: false, error: false }, payload),
|
|
3020
|
-
}));
|
|
3021
|
-
}
|
|
3022
|
-
function* closeDeleteUserDialog({ payload }) {
|
|
3023
|
-
const teamState = yield selectTeamState();
|
|
3024
|
-
const { deleteUserDialogState: { onClose }, } = teamState;
|
|
3025
|
-
onClose === null || onClose === void 0 ? void 0 : onClose(payload);
|
|
3026
|
-
yield put(actions.setTeamState({
|
|
3027
|
-
deleteUserDialogState: {
|
|
3028
|
-
loading: false,
|
|
3029
|
-
error: false,
|
|
3030
|
-
open: false,
|
|
3031
|
-
},
|
|
3032
|
-
}));
|
|
3033
|
-
}
|
|
3034
|
-
function* teamSagas() {
|
|
3035
|
-
yield takeLatest(actions.loadUsers, loadUsers);
|
|
3036
|
-
yield takeLatest(actions.loadAllSubTenantsUsers, loadAllSubTenantsUsers);
|
|
3037
|
-
yield takeLatest(actions.loadRoles, loadRoles);
|
|
3038
|
-
yield takeEvery(actions.addUser, addUser);
|
|
3039
|
-
yield takeEvery(actions.addUserToSubTenants, addUserToSubTenants);
|
|
3040
|
-
yield takeEvery(actions.updateUser, updateUser);
|
|
3041
|
-
yield takeEvery(actions.setUserRolesForSubTenants, setUserRolesForSubTenants);
|
|
3042
|
-
yield takeEvery(actions.deleteUser, deleteUser);
|
|
3043
|
-
yield takeEvery(actions.deleteUserFromSubTenants, deleteUserFromSubTenants);
|
|
3044
|
-
yield takeEvery(actions.resendActivationLink, resendActivationLink);
|
|
3045
|
-
yield takeEvery(actions.resendInvitationLink, resendInvitationLink);
|
|
3046
|
-
yield takeEvery(actions.getInvitationLink, getInvitationLink);
|
|
3047
|
-
yield takeEvery(actions.createInvitationLink, createInvitationLink);
|
|
3048
|
-
yield takeEvery(actions.updateInvitationLink, updateInvitationLink);
|
|
3049
|
-
yield takeEvery(actions.deleteInvitationLink, deleteInvitationLink);
|
|
3050
|
-
yield takeEvery(actions.openAddUserDialog, openAddUserDialog);
|
|
3051
|
-
yield takeEvery(actions.closeAddUserDialog, closeAddUserDialog);
|
|
3052
|
-
yield takeEvery(actions.openDeleteUserDialog, openDeleteUserDialog);
|
|
3053
|
-
yield takeEvery(actions.closeDeleteUserDialog, closeDeleteUserDialog);
|
|
3054
|
-
}
|
|
3055
|
-
/*********************************
|
|
3056
|
-
* Preview Sagas
|
|
3057
|
-
*********************************/
|
|
3058
|
-
function* loadUsersMock({ payload }) {
|
|
3059
|
-
var _a, _b, _c, _d;
|
|
3060
|
-
const { silentLoading, callback } = payload;
|
|
3061
|
-
const teamState = yield selectTeamState();
|
|
3062
|
-
const pageSize = (_a = payload.pageSize) !== null && _a !== void 0 ? _a : teamState.pageSize;
|
|
3063
|
-
const pageOffset = (_b = payload.pageOffset) !== null && _b !== void 0 ? _b : teamState.pageOffset;
|
|
3064
|
-
const filter = (_c = payload.filter) !== null && _c !== void 0 ? _c : teamState.filter;
|
|
3065
|
-
const sort = (_d = payload.sort) !== null && _d !== void 0 ? _d : teamState.sort;
|
|
3066
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.USERS, value: !silentLoading }));
|
|
3067
|
-
yield put(actions.setTeamState({
|
|
3068
|
-
pageSize,
|
|
3069
|
-
pageOffset,
|
|
3070
|
-
filter,
|
|
3071
|
-
sort,
|
|
3072
|
-
}));
|
|
3073
|
-
const totalPages = 2;
|
|
3074
|
-
const totalItems = 10;
|
|
3075
|
-
yield delay();
|
|
3076
|
-
yield put(actions.setTeamState({ users: usersDemo, totalPages, totalItems, roles: rolesDemo, permissions: permissionsDemo }));
|
|
3077
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.USERS, value: false }));
|
|
3078
|
-
callback === null || callback === void 0 ? void 0 : callback(usersDemo);
|
|
3079
|
-
}
|
|
3080
|
-
function* loadAllSubTenantsUsersMock({ payload, }) {
|
|
3081
|
-
var _a, _b, _c, _d, _e;
|
|
3082
|
-
const { silentLoading, callback } = payload;
|
|
3083
|
-
const teamState = yield selectTeamState();
|
|
3084
|
-
const _limit = (_a = payload._limit) !== null && _a !== void 0 ? _a : teamState.allUsersQueryParams._limit;
|
|
3085
|
-
const _offset = (_b = payload._offset) !== null && _b !== void 0 ? _b : teamState.allUsersQueryParams._offset;
|
|
3086
|
-
const _filter = (_c = payload._filter) !== null && _c !== void 0 ? _c : teamState.allUsersQueryParams._filter;
|
|
3087
|
-
const _sortBy = (_d = payload._sortBy) !== null && _d !== void 0 ? _d : teamState.allUsersQueryParams._sortBy;
|
|
3088
|
-
const _order = (_e = payload._order) !== null && _e !== void 0 ? _e : teamState.allUsersQueryParams._order;
|
|
3089
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.USERS, value: !silentLoading }));
|
|
3090
|
-
yield put(actions.setTeamState({
|
|
3091
|
-
allUsersQueryParams: {
|
|
3092
|
-
_limit,
|
|
3093
|
-
_offset,
|
|
3094
|
-
_filter,
|
|
3095
|
-
_sortBy,
|
|
3096
|
-
_order,
|
|
3097
|
-
},
|
|
3098
|
-
}));
|
|
3099
|
-
const totalPages = 2;
|
|
3100
|
-
const totalItems = 10;
|
|
3101
|
-
yield delay();
|
|
3102
|
-
yield put(actions.setTeamState({
|
|
3103
|
-
allUsers: allUsersDemo,
|
|
3104
|
-
totalPages,
|
|
3105
|
-
totalItems,
|
|
3106
|
-
roles: rolesDemo,
|
|
3107
|
-
permissions: permissionsDemo,
|
|
3108
|
-
}));
|
|
3109
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.USERS, value: false }));
|
|
3110
|
-
callback === null || callback === void 0 ? void 0 : callback(allUsersDemo);
|
|
3111
|
-
}
|
|
3112
|
-
function* loadRolesMock({ payload }) {
|
|
3113
|
-
var _a;
|
|
3114
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.ROLES_AND_PERMISSIONS, value: true }));
|
|
3115
|
-
yield delay();
|
|
3116
|
-
yield put(actions.setTeamState({ roles: rolesDemo, permissions: permissionsDemo }));
|
|
3117
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.ROLES_AND_PERMISSIONS, value: true }));
|
|
3118
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, { roles: rolesDemo, permissions: permissionsDemo });
|
|
3119
|
-
}
|
|
3120
|
-
function* addUserMock({ payload }) {
|
|
3121
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
3122
|
-
const teamState = yield selectTeamState();
|
|
3123
|
-
yield put(actions.setTeamState({ addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }) }));
|
|
3124
|
-
yield delay();
|
|
3125
|
-
const newUser = Object.assign(Object.assign(Object.assign({}, userTeamDemo), body), { id: `${v4()}` });
|
|
3126
|
-
callback === null || callback === void 0 ? void 0 : callback(newUser);
|
|
3127
|
-
yield put(actions.setTeamState({
|
|
3128
|
-
users: [newUser, ...teamState.users],
|
|
3129
|
-
addUserDialogState: { open: false, loading: false },
|
|
3130
|
-
}));
|
|
3131
|
-
}
|
|
3132
|
-
function* addUserToSubTenantsMock({ payload }) {
|
|
3133
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
3134
|
-
const teamState = yield selectTeamState();
|
|
3135
|
-
yield put(actions.setTeamState({ addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }) }));
|
|
3136
|
-
yield delay();
|
|
3137
|
-
const newUser = Object.assign(Object.assign(Object.assign({}, userTeamDemo), body), { id: `${v4()}` });
|
|
3138
|
-
yield put(actions.setTeamState({
|
|
3139
|
-
users: [newUser, ...teamState.users],
|
|
3140
|
-
addUserDialogState: { open: false, loading: false },
|
|
3141
|
-
}));
|
|
3142
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
3143
|
-
}
|
|
3144
|
-
function* updateUserMock({ payload }) {
|
|
3145
|
-
var _a;
|
|
3146
|
-
const { callback, profileImage } = payload, body = __rest(payload, ["callback", "profileImage"]);
|
|
3147
|
-
const { id: userId } = body;
|
|
3148
|
-
const teamState = yield selectTeamState();
|
|
3149
|
-
const oldUserData = teamState.users.find((user) => user.id === body.id);
|
|
3150
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.UPDATE_USER, value: userId || '' }));
|
|
3151
|
-
yield put(actions.setTeamState({ addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }) }));
|
|
3152
|
-
yield put(actions.setTeamState({
|
|
3153
|
-
addUserDialogState: Object.assign(Object.assign({}, teamState.addUserDialogState), { loading: true }),
|
|
3154
|
-
users: teamState.users.map((user) => {
|
|
3155
|
-
if (user.id === body.id) {
|
|
3156
|
-
return Object.assign(Object.assign({}, user), body);
|
|
3157
|
-
}
|
|
3158
|
-
return user;
|
|
3159
|
-
}),
|
|
3160
|
-
}));
|
|
3161
|
-
if (oldUserData.roleIds.length > 0 && ((_a = body.roleIds) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
3162
|
-
body.roleIds = [''];
|
|
3163
|
-
}
|
|
3164
|
-
yield delay();
|
|
3165
|
-
const newUser = Object.assign(Object.assign({}, oldUserData), body);
|
|
3166
|
-
callback === null || callback === void 0 ? void 0 : callback(newUser);
|
|
3167
|
-
yield put(actions.setTeamState({
|
|
3168
|
-
users: teamState.users.map((user) => user.id === newUser.id
|
|
3169
|
-
? Object.assign(Object.assign(Object.assign({}, user), newUser), { createdAt: user.createdAt, customData: user.customData, lastLogin: user.lastLogin }) : user),
|
|
3170
|
-
}));
|
|
3171
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.UPDATE_USER, value: false }));
|
|
3172
|
-
}
|
|
3173
|
-
function* deleteUserMock({ payload }) {
|
|
3174
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
3175
|
-
const teamState = yield selectTeamState();
|
|
3176
|
-
yield put(actions.setTeamState({ deleteUserDialogState: Object.assign(Object.assign({}, teamState.deleteUserDialogState), { loading: true }) }));
|
|
3177
|
-
yield delay();
|
|
3178
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
3179
|
-
yield put(actions.setTeamState({
|
|
3180
|
-
users: teamState.users.filter((user) => user.id !== body.userId),
|
|
3181
|
-
deleteUserDialogState: { open: false, loading: false },
|
|
3182
|
-
}));
|
|
3183
|
-
}
|
|
3184
|
-
function* deleteUserFromSubTenantsMock({ payload }) {
|
|
3185
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
3186
|
-
const teamState = yield selectTeamState();
|
|
3187
|
-
yield put(actions.setTeamState({ deleteUserDialogState: Object.assign(Object.assign({}, teamState.deleteUserDialogState), { loading: true }) }));
|
|
3188
|
-
yield delay();
|
|
3189
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
3190
|
-
yield put(actions.setTeamState({
|
|
3191
|
-
allUsers: teamState.allUsers.filter((user) => user.id !== body.userId),
|
|
3192
|
-
deleteUserDialogState: { open: false, loading: false },
|
|
3193
|
-
}));
|
|
3194
|
-
}
|
|
3195
|
-
function* resendActivationLinkMock({ payload }) {
|
|
3196
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
3197
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.RESEND_ACTIVATE_LINK, value: body.userId }));
|
|
3198
|
-
yield delay();
|
|
3199
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
3200
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.RESEND_ACTIVATE_LINK, value: false }));
|
|
3201
|
-
}
|
|
3202
|
-
function* resendInvitationLinkMock({ payload }) {
|
|
3203
|
-
const { callback } = payload, body = __rest(payload, ["callback"]);
|
|
3204
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.RESEND_INVITATION_LINK, value: body.email }));
|
|
3205
|
-
yield delay();
|
|
3206
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
3207
|
-
yield put(actions.setTeamLoader({ key: TeamStateKeys.RESEND_INVITATION_LINK, value: false }));
|
|
3208
|
-
}
|
|
3209
|
-
function* teamSagasMock() {
|
|
3210
|
-
yield takeLatest(actions.loadUsers, loadUsersMock);
|
|
3211
|
-
yield takeLatest(actions.loadAllSubTenantsUsers, loadAllSubTenantsUsersMock);
|
|
3212
|
-
yield takeLatest(actions.loadRoles, loadRolesMock);
|
|
3213
|
-
yield takeEvery(actions.addUser, addUserMock);
|
|
3214
|
-
yield takeEvery(actions.addUserToSubTenants, addUserToSubTenantsMock);
|
|
3215
|
-
yield takeEvery(actions.updateUser, updateUserMock);
|
|
3216
|
-
yield takeEvery(actions.deleteUser, deleteUserMock);
|
|
3217
|
-
yield takeEvery(actions.deleteUserFromSubTenants, deleteUserFromSubTenantsMock);
|
|
3218
|
-
yield takeEvery(actions.resendActivationLink, resendActivationLinkMock);
|
|
3219
|
-
yield takeEvery(actions.resendInvitationLink, resendInvitationLinkMock);
|
|
3220
|
-
yield takeEvery(actions.openAddUserDialog, openAddUserDialog);
|
|
3221
|
-
yield takeEvery(actions.closeAddUserDialog, closeAddUserDialog);
|
|
3222
|
-
yield takeEvery(actions.openDeleteUserDialog, openDeleteUserDialog);
|
|
3223
|
-
yield takeEvery(actions.closeDeleteUserDialog, closeDeleteUserDialog);
|
|
3224
|
-
}
|
|
3225
|
-
|
|
3226
|
-
function* loadSocialLoginsConfigurations() {
|
|
3227
|
-
try {
|
|
3228
|
-
yield put(actions.setSocialLoginsState({ loading: true }));
|
|
3229
|
-
const socialLoginsConfig = yield call(api.auth.getSocialLoginProviders);
|
|
3230
|
-
yield put(actions.setSocialLoginsState({ socialLoginsConfig, loading: false, firstLoad: false }));
|
|
3231
|
-
}
|
|
3232
|
-
catch (e) {
|
|
3233
|
-
yield put(actions.setSocialLoginsState({ error: e.message, loading: false, firstLoad: false }));
|
|
3234
|
-
}
|
|
3235
|
-
}
|
|
3236
|
-
function* loadSocialLoginsConfigurationsV2() {
|
|
3237
|
-
try {
|
|
3238
|
-
const context = yield select((state) => state.root.context);
|
|
3239
|
-
yield put(actions.setSocialLoginsState({ loading: true }));
|
|
3240
|
-
const socialLoginsConfigV2 = yield call(api.auth.getSocialLoginProvidersV2);
|
|
3241
|
-
const socialLoginsConfigWithFullUrl = socialLoginsConfigV2.map((_a) => {
|
|
3242
|
-
var { authorizationUrl } = _a, config = __rest(_a, ["authorizationUrl"]);
|
|
3243
|
-
const baseUrl = fetch.getBaseUrl(context, authorizationUrl !== null && authorizationUrl !== void 0 ? authorizationUrl : '');
|
|
3244
|
-
return (Object.assign(Object.assign({}, config), { authorizationUrl: authorizationUrl ? `${baseUrl}${authorizationUrl}` : null }));
|
|
3245
|
-
});
|
|
3246
|
-
yield put(actions.setSocialLoginsState({ socialLoginsConfigV2: socialLoginsConfigWithFullUrl, loading: false, firstLoad: false }));
|
|
3247
|
-
}
|
|
3248
|
-
catch (e) {
|
|
3249
|
-
yield put(actions.setSocialLoginsState({ error: e.message, loading: false, firstLoad: false }));
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
function* loginViaSocialLogin(_a) {
|
|
3253
|
-
var _b, _c, _d;
|
|
3254
|
-
var _e = _a.payload, { events, url } = _e, payload = __rest(_e, ["events", "url"]);
|
|
3255
|
-
try {
|
|
3256
|
-
yield put(actions.setSocialLoginsState({ loading: true }));
|
|
3257
|
-
const { email, isNewUser, userId, tenantId, name, } = yield call(api.auth.loginViaSocialLogin, payload);
|
|
3258
|
-
if (isNewUser) {
|
|
3259
|
-
(_b = events === null || events === void 0 ? void 0 : events.signUpComplete) === null || _b === void 0 ? void 0 : _b.call(events, {
|
|
3260
|
-
email,
|
|
3261
|
-
url,
|
|
3262
|
-
authenticationType: AuthenticationTypes.SOCIAL_LOGIN,
|
|
3263
|
-
createdAt: new Date(),
|
|
3264
|
-
id: userId,
|
|
3265
|
-
socialProvider: payload.provider,
|
|
3266
|
-
tenantId,
|
|
3267
|
-
});
|
|
3268
|
-
(_c = events === null || events === void 0 ? void 0 : events.userVerified) === null || _c === void 0 ? void 0 : _c.call(events, {
|
|
3269
|
-
email,
|
|
3270
|
-
origin: UserVeirifedOriginTypes.SOCIAL_LOGIN,
|
|
3271
|
-
createdAt: new Date(),
|
|
3272
|
-
id: userId,
|
|
3273
|
-
url,
|
|
3274
|
-
tenantId,
|
|
3275
|
-
name,
|
|
3276
|
-
});
|
|
3277
|
-
}
|
|
3278
|
-
if (email) {
|
|
3279
|
-
localStorage.setItem('email', email);
|
|
3280
|
-
}
|
|
3281
|
-
yield put(actions.setLoginState({ email, isNewUser }));
|
|
3282
|
-
yield refreshToken();
|
|
3283
|
-
yield put(actions.setSocialLoginsState({ loading: false }));
|
|
3284
|
-
}
|
|
3285
|
-
catch (e) {
|
|
3286
|
-
yield put(actions.setSocialLoginsState({ loading: false, error: (_d = e.message) !== null && _d !== void 0 ? _d : 'Failed to authenticate', firstLoad: false }));
|
|
3287
|
-
}
|
|
3288
|
-
}
|
|
3289
|
-
function* setSocialLoginError({ payload }) {
|
|
3290
|
-
yield put(actions.setSocialLoginsState({ error: payload.error, loading: false, firstLoad: false }));
|
|
3291
|
-
}
|
|
3292
|
-
function* socialLoginsSaga() {
|
|
3293
|
-
yield takeLeading(actions.loadSocialLoginsConfiguration, loadSocialLoginsConfigurations);
|
|
3294
|
-
yield takeLeading(actions.loadSocialLoginsConfigurationV2, loadSocialLoginsConfigurationsV2);
|
|
3295
|
-
yield takeLeading(actions.loginViaSocialLogin, loginViaSocialLogin);
|
|
3296
|
-
yield takeLatest(actions.setSocialLoginError, setSocialLoginError);
|
|
3297
|
-
}
|
|
3298
|
-
|
|
3299
|
-
var ApiStateKeys;
|
|
3300
|
-
(function (ApiStateKeys) {
|
|
3301
|
-
ApiStateKeys["LOAD_API_TOKENS"] = "LOAD_API_TOKENS";
|
|
3302
|
-
ApiStateKeys["ADD_API_TOKEN"] = "ADD_API_TOKEN";
|
|
3303
|
-
ApiStateKeys["DELETE_API_TOKEN"] = "DELETE_API_TOKEN";
|
|
3304
|
-
})(ApiStateKeys || (ApiStateKeys = {}));
|
|
3305
|
-
|
|
3306
|
-
function* loadApiTokensData({ payload: apiTokenType }) {
|
|
3307
|
-
yield put(actions.setApiTokensState({ apiTokenType }));
|
|
3308
|
-
try {
|
|
3309
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: true }));
|
|
3310
|
-
if (apiTokenType === 'user') {
|
|
3311
|
-
const apiTokensData = yield call(api.auth.getUserApiTokensData);
|
|
3312
|
-
yield put(actions.setApiTokensState({ apiTokensDataUser: apiTokensData !== null && apiTokensData !== void 0 ? apiTokensData : [] }));
|
|
3313
|
-
}
|
|
3314
|
-
else {
|
|
3315
|
-
const apiTenantTokensData = yield call(api.auth.getTenantApiTokensData);
|
|
3316
|
-
const { items: roles } = yield call(api.teams.loadAvailableRoles);
|
|
3317
|
-
const { items: permissions } = yield call(api.teams.loadAvailablePermissions);
|
|
3318
|
-
yield put(actions.setApiTokensState({
|
|
3319
|
-
apiTokensDataTenant: apiTenantTokensData !== null && apiTenantTokensData !== void 0 ? apiTenantTokensData : [],
|
|
3320
|
-
roles: roles !== null && roles !== void 0 ? roles : [],
|
|
3321
|
-
permissions: permissions !== null && permissions !== void 0 ? permissions : [],
|
|
3322
|
-
}));
|
|
3323
|
-
}
|
|
3324
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: false }));
|
|
3325
|
-
}
|
|
3326
|
-
catch (e) {
|
|
3327
|
-
yield put(actions.setApiTokensError({ key: ApiStateKeys.LOAD_API_TOKENS, value: e.message }));
|
|
3328
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: false }));
|
|
3329
|
-
}
|
|
3330
|
-
}
|
|
3331
|
-
function* addUserApiToken({ payload }) {
|
|
3332
|
-
const { description, callback } = payload;
|
|
3333
|
-
const { apiTokensDataUser } = yield select((state) => state.auth.apiTokensState);
|
|
3334
|
-
try {
|
|
3335
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.ADD_API_TOKEN, value: true }));
|
|
3336
|
-
const data = yield call(api.auth.updateUserApiTokensData, { description });
|
|
3337
|
-
yield put(actions.setApiTokensState({ showAddTokenDialog: false }));
|
|
3338
|
-
yield delay$1(200);
|
|
3339
|
-
yield put(actions.setApiTokensState({
|
|
3340
|
-
apiTokensDataUser: [data, ...apiTokensDataUser],
|
|
3341
|
-
successDialog: { open: true, secret: data.secret, clientId: data.clientId },
|
|
3342
|
-
}));
|
|
3343
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.ADD_API_TOKEN, value: false }));
|
|
3344
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
3345
|
-
}
|
|
3346
|
-
catch (e) {
|
|
3347
|
-
yield put(actions.setApiTokensError({ key: ApiStateKeys.ADD_API_TOKEN, value: e.message }));
|
|
3348
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.ADD_API_TOKEN, value: false }));
|
|
3349
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
|
-
function* addTenantApiToken({ payload }) {
|
|
3353
|
-
const { description, roleIds, callback } = payload;
|
|
3354
|
-
const { apiTokensDataTenant } = yield select((state) => state.auth.apiTokensState);
|
|
3355
|
-
try {
|
|
3356
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.ADD_API_TOKEN, value: true }));
|
|
3357
|
-
const data = yield call(api.auth.updateTenantApiTokensData, { description, roleIds });
|
|
3358
|
-
yield put(actions.setApiTokensState({ showAddTokenDialog: false }));
|
|
3359
|
-
yield delay$1(200);
|
|
3360
|
-
yield put(actions.setApiTokensState({
|
|
3361
|
-
apiTokensDataTenant: [data, ...apiTokensDataTenant],
|
|
3362
|
-
successDialog: { open: true, secret: data.secret, clientId: data.clientId },
|
|
3363
|
-
}));
|
|
3364
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.ADD_API_TOKEN, value: false }));
|
|
3365
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
3366
|
-
}
|
|
3367
|
-
catch (e) {
|
|
3368
|
-
yield put(actions.setApiTokensError({ key: ApiStateKeys.ADD_API_TOKEN, value: e.message }));
|
|
3369
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.ADD_API_TOKEN, value: false }));
|
|
3370
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e.message);
|
|
3371
|
-
}
|
|
3372
|
-
}
|
|
3373
|
-
function* deleteUserApiToken({ payload }) {
|
|
3374
|
-
const { apiTokensDataUser } = yield select((state) => state.auth.apiTokensState);
|
|
3375
|
-
try {
|
|
3376
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.DELETE_API_TOKEN, value: true }));
|
|
3377
|
-
yield call(api.auth.deleteUserApiToken, { tokenId: payload });
|
|
3378
|
-
yield put(actions.setApiTokensState({
|
|
3379
|
-
apiTokensDataUser: apiTokensDataUser.filter((i) => i.clientId !== payload),
|
|
3380
|
-
deleteTokenDialog: { open: false, clientId: payload },
|
|
3381
|
-
}));
|
|
3382
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.DELETE_API_TOKEN, value: false }));
|
|
3383
|
-
}
|
|
3384
|
-
catch (e) {
|
|
3385
|
-
yield put(actions.setApiTokensError({ key: ApiStateKeys.DELETE_API_TOKEN, value: e.message }));
|
|
3386
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.DELETE_API_TOKEN, value: false }));
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
function* deleteTenantApiToken({ payload }) {
|
|
3390
|
-
const { apiTokensDataTenant } = yield select((state) => state.auth.apiTokensState);
|
|
3391
|
-
try {
|
|
3392
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.DELETE_API_TOKEN, value: true }));
|
|
3393
|
-
yield call(api.auth.deleteTenantApiToken, { tokenId: payload });
|
|
3394
|
-
yield put(actions.setApiTokensState({
|
|
3395
|
-
apiTokensDataTenant: apiTokensDataTenant.filter((i) => i.clientId !== payload),
|
|
3396
|
-
deleteTokenDialog: { open: false, clientId: payload },
|
|
3397
|
-
}));
|
|
3398
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.DELETE_API_TOKEN, value: false }));
|
|
3399
|
-
}
|
|
3400
|
-
catch (e) {
|
|
3401
|
-
yield put(actions.setApiTokensError({ key: ApiStateKeys.DELETE_API_TOKEN, value: e.message }));
|
|
3402
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.DELETE_API_TOKEN, value: false }));
|
|
3403
|
-
}
|
|
3404
|
-
}
|
|
3405
|
-
function* loadApiTokens({ payload }) {
|
|
3406
|
-
var _a, _b;
|
|
3407
|
-
if (!(payload === null || payload === void 0 ? void 0 : payload.silentLoading)) {
|
|
3408
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: true }));
|
|
3409
|
-
}
|
|
3410
|
-
try {
|
|
3411
|
-
const [apiTokensDataUser = [], apiTokensDataTenant = []] = yield all([
|
|
3412
|
-
call(api.auth.getUserApiTokensData),
|
|
3413
|
-
call(api.auth.getTenantApiTokensData),
|
|
3414
|
-
]);
|
|
3415
|
-
yield put(actions.setApiTokensState({
|
|
3416
|
-
apiTokensDataUser,
|
|
3417
|
-
apiTokensDataTenant,
|
|
3418
|
-
}));
|
|
3419
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: false }));
|
|
3420
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, true);
|
|
3421
|
-
}
|
|
3422
|
-
catch (e) {
|
|
3423
|
-
yield put(actions.setApiTokensError({ key: ApiStateKeys.LOAD_API_TOKENS, value: e.message }));
|
|
3424
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: false }));
|
|
3425
|
-
(_b = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _b === void 0 ? void 0 : _b.call(payload, null, e);
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
function* apiTokensSaga() {
|
|
3429
|
-
yield takeLeading(actions.loadApiTokens, loadApiTokens);
|
|
3430
|
-
yield takeLeading(actions.initApiTokensData, loadApiTokensData);
|
|
3431
|
-
yield takeEvery(actions.addUserApiToken, addUserApiToken);
|
|
3432
|
-
yield takeEvery(actions.addTenantApiToken, addTenantApiToken);
|
|
3433
|
-
yield takeLatest(actions.deleteTenantApiToken, deleteTenantApiToken);
|
|
3434
|
-
yield takeLatest(actions.deleteUserApiToken, deleteUserApiToken);
|
|
3435
|
-
}
|
|
3436
|
-
/*********************************
|
|
3437
|
-
* Preview Sagas
|
|
3438
|
-
*********************************/
|
|
3439
|
-
function* loadApiTokensDataMock({ payload: apiTokenType }) {
|
|
3440
|
-
var _a;
|
|
3441
|
-
yield put(actions.setApiTokensState({ apiTokenType }));
|
|
3442
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: true }));
|
|
3443
|
-
if (apiTokenType === 'user') {
|
|
3444
|
-
yield delay$1(200);
|
|
3445
|
-
const apiTokensData = [apiTokensDataDemo];
|
|
3446
|
-
yield put(actions.setApiTokensState({ apiTokensDataUser: apiTokensData !== null && apiTokensData !== void 0 ? apiTokensData : [] }));
|
|
3447
|
-
}
|
|
3448
|
-
else {
|
|
3449
|
-
yield delay$1(200);
|
|
3450
|
-
yield put(actions.setApiTokensState({
|
|
3451
|
-
apiTokensDataTenant: (_a = [apiTokensDataTenantDemo]) !== null && _a !== void 0 ? _a : [],
|
|
3452
|
-
roles: rolesDemo !== null && rolesDemo !== void 0 ? rolesDemo : [],
|
|
3453
|
-
permissions: permissionsDemo !== null && permissionsDemo !== void 0 ? permissionsDemo : [],
|
|
3454
|
-
}));
|
|
3455
|
-
}
|
|
3456
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: false }));
|
|
3457
|
-
}
|
|
3458
|
-
function* addTenantApiTokenMock({ payload }) {
|
|
3459
|
-
const { description, roleIds, callback } = payload;
|
|
3460
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.ADD_API_TOKEN, value: true }));
|
|
3461
|
-
const { apiTokensDataTenant } = yield select((state) => state.auth.apiTokensState);
|
|
3462
|
-
const newToken = Object.assign(Object.assign({}, apiTokensDataTenantDemo), { description,
|
|
3463
|
-
roleIds, clientId: `CLIENT_ID_${v4()}` });
|
|
3464
|
-
yield put(actions.setApiTokensState({ showAddTokenDialog: false }));
|
|
3465
|
-
yield delay$1(200);
|
|
3466
|
-
yield put(actions.setApiTokensState({
|
|
3467
|
-
apiTokensDataTenant: [...apiTokensDataTenant, newToken],
|
|
3468
|
-
successDialog: { open: true, secret: newToken.secret, clientId: newToken.clientId },
|
|
3469
|
-
}));
|
|
3470
|
-
yield delay$1(200);
|
|
3471
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.ADD_API_TOKEN, value: false }));
|
|
3472
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
3473
|
-
}
|
|
3474
|
-
function* deleteTenantApiTokenMock({ payload }) {
|
|
3475
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.DELETE_API_TOKEN, value: true }));
|
|
3476
|
-
yield delay$1(200);
|
|
3477
|
-
const apiTokensDataTenant = [apiTokensDataTenantDemo];
|
|
3478
|
-
yield put(actions.setApiTokensState({
|
|
3479
|
-
apiTokensDataTenant: apiTokensDataTenant.filter((i) => i.clientId !== payload),
|
|
3480
|
-
deleteTokenDialog: { open: false, clientId: payload },
|
|
3481
|
-
}));
|
|
3482
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.DELETE_API_TOKEN, value: false }));
|
|
3483
|
-
}
|
|
3484
|
-
function* loadApiTokensMock({ payload }) {
|
|
3485
|
-
var _a;
|
|
3486
|
-
if (!(payload === null || payload === void 0 ? void 0 : payload.silentLoading)) {
|
|
3487
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: true }));
|
|
3488
|
-
}
|
|
3489
|
-
const apiTokensDataUser = [apiTokensDataDemo];
|
|
3490
|
-
const apiTokensDataTenant = [apiTokensDataTenantDemo];
|
|
3491
|
-
yield put(actions.setApiTokensState({
|
|
3492
|
-
apiTokensDataUser,
|
|
3493
|
-
apiTokensDataTenant,
|
|
3494
|
-
}));
|
|
3495
|
-
yield delay$1(200);
|
|
3496
|
-
yield put(actions.setApiTokensLoader({ key: ApiStateKeys.LOAD_API_TOKENS, value: false }));
|
|
3497
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, true);
|
|
3498
|
-
}
|
|
3499
|
-
function* apiTokensSagaMock() {
|
|
3500
|
-
yield takeLeading(actions.loadApiTokens, loadApiTokensMock);
|
|
3501
|
-
yield takeLeading(actions.initApiTokensData, loadApiTokensDataMock);
|
|
3502
|
-
yield takeEvery(actions.addTenantApiToken, addTenantApiTokenMock);
|
|
3503
|
-
yield takeLatest(actions.deleteTenantApiToken, deleteTenantApiTokenMock);
|
|
3504
|
-
}
|
|
3505
|
-
|
|
3506
|
-
function* loadSecurityPolicy() {
|
|
3507
|
-
yield put(actions.setSecurityPolicyGlobalState({ loading: true, error: null }));
|
|
3508
|
-
try {
|
|
3509
|
-
const policy = yield call(api.auth.getGlobalSecurityPolicy);
|
|
3510
|
-
yield put(actions.setSecurityPolicyGlobalState({ policy, loading: false }));
|
|
3511
|
-
}
|
|
3512
|
-
catch (e) {
|
|
3513
|
-
yield put(actions.setSecurityPolicyGlobalState({ error: e.message, loading: false }));
|
|
3514
|
-
}
|
|
3515
|
-
yield put(actions.loadSecurityPolicyMfa());
|
|
3516
|
-
yield put(actions.loadSecurityPolicyVendorMfa());
|
|
3517
|
-
yield put(actions.loadSecurityPolicyLockout());
|
|
3518
|
-
yield put(actions.loadSecurityPolicyCaptcha());
|
|
3519
|
-
yield put(actions.loadPublicAuthStrategiesPolicy());
|
|
3520
|
-
}
|
|
3521
|
-
function* loadPublicSecurityPolicy() {
|
|
3522
|
-
yield put(actions.setSecurityPolicyPublicState({ loading: true, error: null }));
|
|
3523
|
-
try {
|
|
3524
|
-
const policy = yield call(api.auth.getVendorConfig);
|
|
3525
|
-
yield put(actions.setSecurityPolicyPublicState({ policy, loading: false }));
|
|
3526
|
-
}
|
|
3527
|
-
catch (e) {
|
|
3528
|
-
yield put(actions.setSecurityPolicyPublicState({ error: e.message, loading: false }));
|
|
3529
|
-
}
|
|
3530
|
-
}
|
|
3531
|
-
function* loadPublicAuthStrategiesPolicy() {
|
|
3532
|
-
yield put(actions.setSecurityPolicyAuthStrategyPublicState({ loading: true, error: null }));
|
|
3533
|
-
try {
|
|
3534
|
-
const policy = yield call(api.auth.getVendorPublicAuthStrategiesConfig);
|
|
3535
|
-
yield put(actions.setSecurityPolicyAuthStrategyPublicState({ policy, loading: false }));
|
|
3536
|
-
}
|
|
3537
|
-
catch (e) {
|
|
3538
|
-
yield put(actions.setSecurityPolicyAuthStrategyPublicState({ error: e.message, loading: false }));
|
|
3539
|
-
}
|
|
3540
|
-
}
|
|
3541
|
-
function* loadSecurityPolicyMfa() {
|
|
3542
|
-
yield put(actions.setSecurityPolicyMfaState({ loading: true, error: null }));
|
|
3543
|
-
try {
|
|
3544
|
-
const policy = yield call(api.auth.getMfaPolicy);
|
|
3545
|
-
yield put(actions.setSecurityPolicyMfaState({ policy, loading: false }));
|
|
3546
|
-
}
|
|
3547
|
-
catch (e) {
|
|
3548
|
-
yield put(actions.setSecurityPolicyMfaState({ error: e.message, loading: false }));
|
|
3549
|
-
}
|
|
3550
|
-
}
|
|
3551
|
-
function* loadSecurityPolicyVendorMfa() {
|
|
3552
|
-
yield put(actions.setSecurityPolicyMfaState({ loading: true, error: null }));
|
|
3553
|
-
try {
|
|
3554
|
-
const policy = yield call(api.auth.getVendorMfaPolicy);
|
|
3555
|
-
yield put(actions.setSecurityPolicyVendorMfaState({ policy, loading: false }));
|
|
3556
|
-
}
|
|
3557
|
-
catch (e) {
|
|
3558
|
-
yield put(actions.setSecurityPolicyVendorMfaState({ error: e.message, loading: false }));
|
|
3559
|
-
}
|
|
3560
|
-
}
|
|
3561
|
-
function* saveSecurityPolicyMfa(_a) {
|
|
3562
|
-
var _b = _a.payload, { callback } = _b, newSecurityPolicy = __rest(_b, ["callback"]);
|
|
3563
|
-
yield put(actions.setSecurityPolicyMfaState({ saving: true, error: null }));
|
|
3564
|
-
try {
|
|
3565
|
-
const policy = yield call(api.auth.saveMfaPolicy, newSecurityPolicy);
|
|
3566
|
-
yield put(actions.setSecurityPolicyMfaState({ policy, saving: false }));
|
|
3567
|
-
callback === null || callback === void 0 ? void 0 : callback(policy);
|
|
3568
|
-
}
|
|
3569
|
-
catch (e) {
|
|
3570
|
-
yield put(actions.setSecurityPolicyMfaState({ saving: false, error: e.message }));
|
|
3571
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3572
|
-
}
|
|
3573
|
-
}
|
|
3574
|
-
function* loadSecurityPolicyLockout() {
|
|
3575
|
-
yield put(actions.setSecurityPolicyLockoutState({ loading: true, error: null }));
|
|
3576
|
-
try {
|
|
3577
|
-
const policy = yield call(api.auth.getLockoutPolicy);
|
|
3578
|
-
yield put(actions.setSecurityPolicyLockoutState({ policy, loading: false }));
|
|
3579
|
-
}
|
|
3580
|
-
catch (e) {
|
|
3581
|
-
yield put(actions.setSecurityPolicyLockoutState({ error: e.message, loading: false }));
|
|
3582
|
-
}
|
|
3583
|
-
}
|
|
3584
|
-
function* saveSecurityPolicyLockout(_a) {
|
|
3585
|
-
var _b = _a.payload, { callback } = _b, newSecurityPolicy = __rest(_b, ["callback"]);
|
|
3586
|
-
yield put(actions.setSecurityPolicyLockoutState({ saving: true, error: null }));
|
|
3587
|
-
try {
|
|
3588
|
-
const policy = yield call(api.auth.saveLockoutPolicy, newSecurityPolicy);
|
|
3589
|
-
yield put(actions.setSecurityPolicyLockoutState({ policy, saving: false }));
|
|
3590
|
-
callback === null || callback === void 0 ? void 0 : callback(policy);
|
|
3591
|
-
}
|
|
3592
|
-
catch (e) {
|
|
3593
|
-
yield put(actions.setSecurityPolicyLockoutState({ saving: false, error: e.message }));
|
|
3594
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3595
|
-
}
|
|
3596
|
-
}
|
|
3597
|
-
function* loadSecurityPolicyCaptcha() {
|
|
3598
|
-
yield put(actions.setSecurityPolicyLockoutState({ loading: true, error: null }));
|
|
3599
|
-
try {
|
|
3600
|
-
const policy = yield call(api.auth.getCaptchaPolicy);
|
|
3601
|
-
yield put(actions.setSecurityPolicyCaptchaState({ policy, loading: false }));
|
|
3602
|
-
}
|
|
3603
|
-
catch (e) {
|
|
3604
|
-
yield put(actions.setSecurityPolicyCaptchaState({ error: e.message, loading: false }));
|
|
3605
|
-
}
|
|
3606
|
-
}
|
|
3607
|
-
function* loadSecurityPolicyPasswordHistory() {
|
|
3608
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ loading: true, error: null }));
|
|
3609
|
-
try {
|
|
3610
|
-
const policy = yield call(api.auth.getPasswordHistoryPolicy);
|
|
3611
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ policy, loading: false }));
|
|
3612
|
-
}
|
|
3613
|
-
catch (e) {
|
|
3614
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ error: e.message, loading: false }));
|
|
3615
|
-
}
|
|
3616
|
-
}
|
|
3617
|
-
function* saveSecurityPolicyPasswordHistory(_a) {
|
|
3618
|
-
var _b = _a.payload, { callback } = _b, newSecurityPolicy = __rest(_b, ["callback"]);
|
|
3619
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ saving: true, error: null }));
|
|
3620
|
-
try {
|
|
3621
|
-
const policy = yield call(api.auth.savePasswordHistoryPolicy, newSecurityPolicy);
|
|
3622
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ policy, saving: false }));
|
|
3623
|
-
callback === null || callback === void 0 ? void 0 : callback(policy);
|
|
3624
|
-
}
|
|
3625
|
-
catch (e) {
|
|
3626
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ saving: false, error: e.message }));
|
|
3627
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3628
|
-
}
|
|
3629
|
-
}
|
|
3630
|
-
function* loadVendorPasswordConfig() {
|
|
3631
|
-
yield put(actions.setSecurityPolicyPasswordState({ loading: true, error: null }));
|
|
3632
|
-
try {
|
|
3633
|
-
const policy = yield call(api.auth.getPasswordConfigPolicy);
|
|
3634
|
-
yield put(actions.setSecurityPolicyPasswordState({ policy, loading: false }));
|
|
3635
|
-
}
|
|
3636
|
-
catch (e) {
|
|
3637
|
-
yield put(actions.setSecurityPolicyPasswordState({ error: e.message, loading: false }));
|
|
3638
|
-
}
|
|
3639
|
-
}
|
|
3640
|
-
function* securityPolicySagas() {
|
|
3641
|
-
yield takeLeading(actions.loadSecurityPolicy, loadSecurityPolicy);
|
|
3642
|
-
yield takeEvery(actions.saveSecurityPolicyMfa, saveSecurityPolicyMfa);
|
|
3643
|
-
yield takeEvery(actions.loadSecurityPolicyMfa, loadSecurityPolicyMfa);
|
|
3644
|
-
yield takeEvery(actions.loadSecurityPolicyVendorMfa, loadSecurityPolicyVendorMfa);
|
|
3645
|
-
yield takeEvery(actions.saveSecurityPolicyLockout, saveSecurityPolicyLockout);
|
|
3646
|
-
yield takeEvery(actions.loadSecurityPolicyLockout, loadSecurityPolicyLockout);
|
|
3647
|
-
yield takeEvery(actions.loadSecurityPolicyCaptcha, loadSecurityPolicyCaptcha);
|
|
3648
|
-
yield takeEvery(actions.saveSecurityPolicyPasswordHistory, saveSecurityPolicyPasswordHistory);
|
|
3649
|
-
yield takeEvery(actions.loadSecurityPolicyPasswordHistory, loadSecurityPolicyPasswordHistory);
|
|
3650
|
-
yield takeEvery(actions.loadVendorPasswordConfig, loadVendorPasswordConfig);
|
|
3651
|
-
yield takeEvery(actions.loadPublicSecurityPolicy, loadPublicSecurityPolicy);
|
|
3652
|
-
yield takeEvery(actions.loadPublicAuthStrategiesPolicy, loadPublicAuthStrategiesPolicy);
|
|
3653
|
-
}
|
|
3654
|
-
/*********************************
|
|
3655
|
-
* Preview Sagas
|
|
3656
|
-
*********************************/
|
|
3657
|
-
function* loadPublicSecurityPolicyMock() {
|
|
3658
|
-
yield put(actions.setSecurityPolicyPublicState({ loading: true, error: null }));
|
|
3659
|
-
try {
|
|
3660
|
-
yield put(actions.setSecurityPolicyPublicState({ policy: publicSecurityPolicy, loading: false }));
|
|
3661
|
-
}
|
|
3662
|
-
catch (e) {
|
|
3663
|
-
yield put(actions.setSecurityPolicyPublicState({ error: e.message, loading: false }));
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
function* loadSecurityPolicyMock() {
|
|
3667
|
-
yield put(actions.setSecurityPolicyGlobalState({ loading: true, error: null }));
|
|
3668
|
-
yield delay();
|
|
3669
|
-
yield put(actions.setSecurityPolicyGlobalState({ policy: policyDemo, loading: false }));
|
|
3670
|
-
yield put(actions.loadSecurityPolicyMfa());
|
|
3671
|
-
yield put(actions.loadSecurityPolicyVendorMfa());
|
|
3672
|
-
yield put(actions.loadSecurityPolicyLockout());
|
|
3673
|
-
yield put(actions.loadSecurityPolicyCaptcha());
|
|
3674
|
-
}
|
|
3675
|
-
function* loadSecurityPolicyMfaMock() {
|
|
3676
|
-
yield put(actions.setSecurityPolicyMfaState({ loading: true, error: null }));
|
|
3677
|
-
yield delay();
|
|
3678
|
-
yield put(actions.setSecurityPolicyMfaState({ policy: policyMfaDemo, loading: false }));
|
|
3679
|
-
}
|
|
3680
|
-
function* loadSecurityPolicyVendorMfaMock() {
|
|
3681
|
-
yield put(actions.setSecurityPolicyVendorMfaState({ loading: true, error: null }));
|
|
3682
|
-
yield delay();
|
|
3683
|
-
yield put(actions.setSecurityPolicyVendorMfaState({ policy: policyMfaDemo, loading: false }));
|
|
3684
|
-
}
|
|
3685
|
-
function* saveSecurityPolicyMfaMock(_a) {
|
|
3686
|
-
var _b;
|
|
3687
|
-
var _c = _a.payload, { callback } = _c, newSecurityPolicy = __rest(_c, ["callback"]);
|
|
3688
|
-
yield put(actions.setSecurityPolicyMfaState({ saving: true, error: null }));
|
|
3689
|
-
const policy = Object.assign(Object.assign({}, policyLockoutDemo), { id: (_b = newSecurityPolicy.id) !== null && _b !== void 0 ? _b : policyLockoutDemo.id, enforceMFAType: newSecurityPolicy.enforceMFAType });
|
|
3690
|
-
yield delay();
|
|
3691
|
-
yield put(actions.setSecurityPolicyMfaState({ policy, saving: false }));
|
|
3692
|
-
callback === null || callback === void 0 ? void 0 : callback(policy);
|
|
3693
|
-
}
|
|
3694
|
-
function* loadSecurityPolicyLockoutMock() {
|
|
3695
|
-
yield put(actions.setSecurityPolicyLockoutState({ loading: true, error: null }));
|
|
3696
|
-
yield delay();
|
|
3697
|
-
yield put(actions.setSecurityPolicyLockoutState({ policy: policyLockoutDemo, loading: false }));
|
|
3698
|
-
}
|
|
3699
|
-
function* saveSecurityPolicyLockoutMock(_a) {
|
|
3700
|
-
var _b = _a.payload, { callback } = _b, newSecurityPolicy = __rest(_b, ["callback"]);
|
|
3701
|
-
yield put(actions.setSecurityPolicyLockoutState({ saving: true, error: null }));
|
|
3702
|
-
yield delay();
|
|
3703
|
-
const policy = Object.assign(Object.assign(Object.assign({}, newSecurityPolicy), policyLockoutDemo), { id: newSecurityPolicy.id ? newSecurityPolicy.id : policyLockoutDemo.id });
|
|
3704
|
-
callback === null || callback === void 0 ? void 0 : callback(policy);
|
|
3705
|
-
yield put(actions.setSecurityPolicyLockoutState({ policy, saving: false }));
|
|
3706
|
-
}
|
|
3707
|
-
function* loadSecurityPolicyCaptchaMock() {
|
|
3708
|
-
yield put(actions.setSecurityPolicyLockoutState({ loading: true, error: null }));
|
|
3709
|
-
yield delay();
|
|
3710
|
-
yield put(actions.setSecurityPolicyLockoutState({ policy: policyLockoutDemo, loading: false }));
|
|
3711
|
-
}
|
|
3712
|
-
function* loadSecurityPolicyPasswordHistoryMock() {
|
|
3713
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ loading: true, error: null }));
|
|
3714
|
-
yield delay();
|
|
3715
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ policy: policyPasswordHistoryDemo, loading: false }));
|
|
3716
|
-
}
|
|
3717
|
-
function* saveSecurityPolicyPasswordHistoryMock(_a) {
|
|
3718
|
-
var _b = _a.payload, { callback } = _b, newSecurityPolicy = __rest(_b, ["callback"]);
|
|
3719
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ saving: true, error: null }));
|
|
3720
|
-
yield delay();
|
|
3721
|
-
const policy = Object.assign(Object.assign(Object.assign({}, newSecurityPolicy), policyPasswordHistoryDemo), { id: newSecurityPolicy.id ? newSecurityPolicy.id : policyPasswordHistoryDemo.id });
|
|
3722
|
-
callback === null || callback === void 0 ? void 0 : callback(policy);
|
|
3723
|
-
yield put(actions.setSecurityPolicyPasswordHistoryState({ policy, saving: false }));
|
|
3724
|
-
}
|
|
3725
|
-
function* securityPolicySagasMock() {
|
|
3726
|
-
yield takeLeading(actions.loadSecurityPolicy, loadSecurityPolicyMock);
|
|
3727
|
-
yield takeEvery(actions.loadPublicSecurityPolicy, loadPublicSecurityPolicyMock);
|
|
3728
|
-
yield takeEvery(actions.saveSecurityPolicyMfa, saveSecurityPolicyMfaMock);
|
|
3729
|
-
yield takeEvery(actions.loadSecurityPolicyMfa, loadSecurityPolicyMfaMock);
|
|
3730
|
-
yield takeEvery(actions.loadSecurityPolicyVendorMfa, loadSecurityPolicyVendorMfaMock);
|
|
3731
|
-
yield takeEvery(actions.saveSecurityPolicyLockout, saveSecurityPolicyLockoutMock);
|
|
3732
|
-
yield takeEvery(actions.loadSecurityPolicyLockout, loadSecurityPolicyLockoutMock);
|
|
3733
|
-
yield takeEvery(actions.loadSecurityPolicyCaptcha, loadSecurityPolicyCaptchaMock);
|
|
3734
|
-
yield takeEvery(actions.saveSecurityPolicyPasswordHistory, saveSecurityPolicyPasswordHistoryMock);
|
|
3735
|
-
yield takeEvery(actions.loadSecurityPolicyPasswordHistory, loadSecurityPolicyPasswordHistoryMock);
|
|
3736
|
-
}
|
|
3737
|
-
|
|
3738
|
-
function* saveAccountSettings({ payload }) {
|
|
3739
|
-
var _a, _b;
|
|
3740
|
-
try {
|
|
3741
|
-
yield put(actions.setAccountSettingsState({ loading: true }));
|
|
3742
|
-
const { accountSettingsState } = yield select((state) => state.auth);
|
|
3743
|
-
const { address, timezone, dateFormat, timeFormat, currency, logo } = accountSettingsState;
|
|
3744
|
-
const body = yield call(api.accountSettings.updateSettings, Object.assign({ address,
|
|
3745
|
-
timezone,
|
|
3746
|
-
dateFormat,
|
|
3747
|
-
timeFormat,
|
|
3748
|
-
currency,
|
|
3749
|
-
logo }, payload));
|
|
3750
|
-
yield put(actions.setAccountSettingsState(Object.assign(Object.assign({}, body), { loading: false })));
|
|
3751
|
-
(_a = payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, body);
|
|
3752
|
-
}
|
|
3753
|
-
catch (e) {
|
|
3754
|
-
yield put(actions.setAccountSettingsState({ loading: false, error: e.message }));
|
|
3755
|
-
(_b = payload.callback) === null || _b === void 0 ? void 0 : _b.call(payload, null, e);
|
|
3756
|
-
}
|
|
3757
|
-
}
|
|
3758
|
-
function* loadAccountSettings({ payload }) {
|
|
3759
|
-
yield put(actions.setAccountSettingsState({ loading: !(payload === null || payload === void 0 ? void 0 : payload.silentLoading), error: null }));
|
|
3760
|
-
try {
|
|
3761
|
-
const body = yield call(api.accountSettings.getSettings);
|
|
3762
|
-
yield put(actions.setAccountSettingsState(Object.assign(Object.assign({}, body), { loading: false })));
|
|
3763
|
-
}
|
|
3764
|
-
catch (e) {
|
|
3765
|
-
yield put(actions.setAccountSettingsState({ loading: false, error: e.message }));
|
|
3766
|
-
}
|
|
3767
|
-
}
|
|
3768
|
-
function* accountSettingsSaga() {
|
|
3769
|
-
yield takeLeading(actions.saveAccountSettings, saveAccountSettings);
|
|
3770
|
-
yield takeLeading(actions.loadAccountSettings, loadAccountSettings);
|
|
3771
|
-
}
|
|
3772
|
-
/*********************************
|
|
3773
|
-
* Preview Sagas
|
|
3774
|
-
*********************************/
|
|
3775
|
-
function* saveAccountSettingsMock({ payload }) {
|
|
3776
|
-
var _a;
|
|
3777
|
-
yield put(actions.setAccountSettingsState({ loading: true }));
|
|
3778
|
-
yield delay();
|
|
3779
|
-
const { accountSettingsState } = yield select((state) => state.auth);
|
|
3780
|
-
const { address, timezone, dateFormat, timeFormat, currency, logo } = accountSettingsState;
|
|
3781
|
-
const body = Object.assign({ address,
|
|
3782
|
-
timezone,
|
|
3783
|
-
dateFormat,
|
|
3784
|
-
timeFormat,
|
|
3785
|
-
currency,
|
|
3786
|
-
logo }, payload);
|
|
3787
|
-
yield put(actions.setAccountSettingsState(Object.assign(Object.assign({}, body), { loading: false })));
|
|
3788
|
-
(_a = payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, body);
|
|
3789
|
-
}
|
|
3790
|
-
function* loadAccountSettingsMock({ payload }) {
|
|
3791
|
-
yield put(actions.setAccountSettingsState({ loading: !(payload === null || payload === void 0 ? void 0 : payload.silentLoading), error: null }));
|
|
3792
|
-
yield delay();
|
|
3793
|
-
yield put(actions.setAccountSettingsState({
|
|
3794
|
-
address: 'Tel-aviv',
|
|
3795
|
-
timezone: 'Asia/Jerusalem',
|
|
3796
|
-
dateFormat: 'DD/MM/YYYY',
|
|
3797
|
-
timeFormat: 'HH:mm',
|
|
3798
|
-
currency: 'USD',
|
|
3799
|
-
loading: false,
|
|
3800
|
-
}));
|
|
3801
|
-
}
|
|
3802
|
-
function* accountSettingsSagaMock() {
|
|
3803
|
-
yield takeLeading(actions.saveAccountSettings, saveAccountSettingsMock);
|
|
3804
|
-
yield takeLeading(actions.loadAccountSettings, loadAccountSettingsMock);
|
|
3805
|
-
}
|
|
3806
|
-
|
|
3807
|
-
function* switchTenant({ payload: { tenantId, callback } }) {
|
|
3808
|
-
yield put(actions.setState({ isLoading: true }));
|
|
3809
|
-
try {
|
|
3810
|
-
yield call(api.tenants.switchTenant, { tenantId });
|
|
3811
|
-
yield call(refreshToken);
|
|
3812
|
-
const callbackConsumed = callback === null || callback === void 0 ? void 0 : callback(true);
|
|
3813
|
-
if (!callbackConsumed) {
|
|
3814
|
-
yield put(actions.setState({ isLoading: false }));
|
|
3815
|
-
}
|
|
3816
|
-
}
|
|
3817
|
-
catch (e) {
|
|
3818
|
-
yield put(actions.setState({ isLoading: false }));
|
|
3819
|
-
callback === null || callback === void 0 ? void 0 : callback(false, e);
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
function* loadTenants({ payload }) {
|
|
3823
|
-
var _a, _b;
|
|
3824
|
-
yield put(actions.setTenantsState({ loading: true }));
|
|
3825
|
-
try {
|
|
3826
|
-
const tenants = yield call(api.tenants.getTenants);
|
|
3827
|
-
yield put(actions.setTenantsState({ tenants, loading: false }));
|
|
3828
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, []);
|
|
3829
|
-
}
|
|
3830
|
-
catch (e) {
|
|
3831
|
-
(_b = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _b === void 0 ? void 0 : _b.call(payload, [], e);
|
|
3832
|
-
yield put(actions.setTenantsState({ loading: false }));
|
|
3833
|
-
}
|
|
3834
|
-
}
|
|
3835
|
-
function* loadSubTenants({ payload }) {
|
|
3836
|
-
var _a, _b;
|
|
3837
|
-
yield put(actions.setTenantsState({ loading: true }));
|
|
3838
|
-
try {
|
|
3839
|
-
const subTenants = yield call(api.tenants.getSubTenants);
|
|
3840
|
-
yield put(actions.setTenantsState({ subTenants, loading: false }));
|
|
3841
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, true);
|
|
3842
|
-
}
|
|
3843
|
-
catch (e) {
|
|
3844
|
-
yield put(actions.setTenantsState({ loading: false }));
|
|
3845
|
-
(_b = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _b === void 0 ? void 0 : _b.call(payload, null, e);
|
|
3846
|
-
}
|
|
3847
|
-
}
|
|
3848
|
-
function* loadSubTenantsTree({ payload }) {
|
|
3849
|
-
var _a, _b;
|
|
3850
|
-
yield put(actions.setTenantsState({ loading: true }));
|
|
3851
|
-
try {
|
|
3852
|
-
const tenantTree = yield call(api.tenants.getSubTenantsAsTree);
|
|
3853
|
-
yield put(actions.setTenantsState({ tenantTree, loading: false }));
|
|
3854
|
-
(_a = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _a === void 0 ? void 0 : _a.call(payload, true);
|
|
3855
|
-
}
|
|
3856
|
-
catch (e) {
|
|
3857
|
-
yield put(actions.setTenantsState({ loading: false }));
|
|
3858
|
-
(_b = payload === null || payload === void 0 ? void 0 : payload.callback) === null || _b === void 0 ? void 0 : _b.call(payload, null, e);
|
|
3859
|
-
}
|
|
3860
|
-
}
|
|
3861
|
-
function* tenantsSagas() {
|
|
3862
|
-
yield takeEvery(actions.loadTenants, loadTenants);
|
|
3863
|
-
yield takeEvery(actions.loadSubTenants, loadSubTenants);
|
|
3864
|
-
yield takeEvery(actions.switchTenant, switchTenant);
|
|
3865
|
-
yield takeEvery(actions.loadSubTenantsTree, loadSubTenantsTree);
|
|
3866
|
-
}
|
|
3867
|
-
/*********************************
|
|
3868
|
-
* Preview Sagas
|
|
3869
|
-
*********************************/
|
|
3870
|
-
function* loadTenantsMock({}) {
|
|
3871
|
-
yield put(actions.setTenantsState({ loading: true }));
|
|
3872
|
-
yield delay();
|
|
3873
|
-
yield put(actions.setTenantsState({ tenants: tenantsDemo, loading: false }));
|
|
3874
|
-
}
|
|
3875
|
-
function* tenantsSagasMock() {
|
|
3876
|
-
yield takeEvery(actions.loadTenants, loadTenantsMock);
|
|
3877
|
-
}
|
|
3878
|
-
|
|
3879
|
-
function* loadRolesAndPermissions({ payload }) {
|
|
3880
|
-
var _a;
|
|
3881
|
-
yield put(actions.setRolesState({ loading: !((_a = payload === null || payload === void 0 ? void 0 : payload.silentLoading) !== null && _a !== void 0 ? _a : false), error: null }));
|
|
3882
|
-
try {
|
|
3883
|
-
const result = yield all([
|
|
3884
|
-
call(api.roles.getRoles),
|
|
3885
|
-
call(api.roles.getPermissions),
|
|
3886
|
-
call(api.roles.getPermissionCategories),
|
|
3887
|
-
]);
|
|
3888
|
-
const [roles, permissions, permissionCategories] = result;
|
|
3889
|
-
yield put(actions.setRolesState({ roles, permissions, permissionCategories, loading: false }));
|
|
3890
|
-
}
|
|
3891
|
-
catch (e) {
|
|
3892
|
-
yield put(actions.setRolesState({ error: e.message, loading: false }));
|
|
3893
|
-
}
|
|
3894
|
-
}
|
|
3895
|
-
function* addRole(_a) {
|
|
3896
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
3897
|
-
yield put(actions.setRolesState({ saving: true }));
|
|
3898
|
-
try {
|
|
3899
|
-
const role = yield call(api.roles.addRole, body);
|
|
3900
|
-
const roles = yield call(api.roles.getRoles);
|
|
3901
|
-
yield put(actions.loadRolesAndPermissions({ silentLoading: true }));
|
|
3902
|
-
yield put(actions.setRolesState({ roles, saving: false }));
|
|
3903
|
-
callback === null || callback === void 0 ? void 0 : callback(role);
|
|
3904
|
-
}
|
|
3905
|
-
catch (e) {
|
|
3906
|
-
yield put(actions.setRolesState({ error: e.message, saving: false }));
|
|
3907
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3908
|
-
}
|
|
3909
|
-
}
|
|
3910
|
-
function* deleteRole(_a) {
|
|
3911
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
3912
|
-
yield put(actions.setRolesState({ saving: true }));
|
|
3913
|
-
try {
|
|
3914
|
-
yield call(api.roles.deleteRole, body);
|
|
3915
|
-
yield put(actions.loadRolesAndPermissions({ silentLoading: true }));
|
|
3916
|
-
yield put(actions.setRolesState({ saving: false }));
|
|
3917
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
3918
|
-
}
|
|
3919
|
-
catch (e) {
|
|
3920
|
-
yield put(actions.setRolesState({ error: e.message, saving: false }));
|
|
3921
|
-
callback === null || callback === void 0 ? void 0 : callback(false, e);
|
|
3922
|
-
}
|
|
3923
|
-
}
|
|
3924
|
-
function* updateRole(_a) {
|
|
3925
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
3926
|
-
yield put(actions.setRolesState({ saving: true }));
|
|
3927
|
-
try {
|
|
3928
|
-
const role = yield call(api.roles.updateRole, body);
|
|
3929
|
-
yield put(actions.loadRolesAndPermissions({ silentLoading: true }));
|
|
3930
|
-
yield put(actions.setRolesState({ saving: false }));
|
|
3931
|
-
callback === null || callback === void 0 ? void 0 : callback(role);
|
|
3932
|
-
}
|
|
3933
|
-
catch (e) {
|
|
3934
|
-
yield put(actions.setRolesState({ error: e.message, saving: false }));
|
|
3935
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3936
|
-
}
|
|
3937
|
-
}
|
|
3938
|
-
function* attachPermissionsToRole(_a) {
|
|
3939
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
3940
|
-
yield put(actions.setRolesState({ saving: true }));
|
|
3941
|
-
try {
|
|
3942
|
-
const role = yield call(api.roles.attachPermissionsToRole, body);
|
|
3943
|
-
yield put(actions.loadRolesAndPermissions({ silentLoading: true }));
|
|
3944
|
-
yield put(actions.setRolesState({ saving: false }));
|
|
3945
|
-
callback === null || callback === void 0 ? void 0 : callback(role);
|
|
3946
|
-
}
|
|
3947
|
-
catch (e) {
|
|
3948
|
-
yield put(actions.setRolesState({ error: e.message, saving: false }));
|
|
3949
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3950
|
-
}
|
|
3951
|
-
}
|
|
3952
|
-
function* attachPermissionToRoles(_a) {
|
|
3953
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
3954
|
-
yield put(actions.setRolesState({ saving: true }));
|
|
3955
|
-
try {
|
|
3956
|
-
const permission = yield call(api.roles.attachPermissionToRoles, body);
|
|
3957
|
-
yield put(actions.loadRolesAndPermissions({ silentLoading: true }));
|
|
3958
|
-
yield put(actions.setRolesState({ saving: false }));
|
|
3959
|
-
callback === null || callback === void 0 ? void 0 : callback(permission);
|
|
3960
|
-
}
|
|
3961
|
-
catch (e) {
|
|
3962
|
-
yield put(actions.setRolesState({ error: e.message, saving: false }));
|
|
3963
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
3966
|
-
function* rolesSagas() {
|
|
3967
|
-
yield takeLeading(actions.loadRolesAndPermissions, loadRolesAndPermissions);
|
|
3968
|
-
yield takeEvery(actions.addRole, addRole);
|
|
3969
|
-
yield takeEvery(actions.deleteRole, deleteRole);
|
|
3970
|
-
yield takeEvery(actions.updateRole, updateRole);
|
|
3971
|
-
yield takeEvery(actions.attachPermissionsToRole, attachPermissionsToRole);
|
|
3972
|
-
yield takeEvery(actions.attachPermissionToRoles, attachPermissionToRoles);
|
|
3973
|
-
}
|
|
3974
|
-
|
|
3975
|
-
function* resetPhoneNumber(_a) {
|
|
3976
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
3977
|
-
yield put(actions.setResetPhoneNumberState({ loading: true }));
|
|
3978
|
-
try {
|
|
3979
|
-
const res = yield call(api.auth.resetPhoneNumber, body);
|
|
3980
|
-
yield put(actions.setResetPhoneNumberState({ loading: false, error: undefined, resetPhoneNumberToken: res.resetPhoneNumberToken, step: ResetPhoneNumberStep.VerifyResetPhoneNumber }));
|
|
3981
|
-
yield put(actions.setLoginState({ email: body.email }));
|
|
3982
|
-
}
|
|
3983
|
-
catch (e) {
|
|
3984
|
-
yield put(actions.setResetPhoneNumberState({ loading: false, error: e.message }));
|
|
3985
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3986
|
-
}
|
|
3987
|
-
}
|
|
3988
|
-
function* verifyResetPhoneNumber(_a) {
|
|
3989
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
3990
|
-
yield put(actions.setResetPhoneNumberState({ loading: true }));
|
|
3991
|
-
try {
|
|
3992
|
-
const res = yield call(api.auth.verifyResetPhoneNumber, body);
|
|
3993
|
-
yield put(actions.setResetPhoneNumberState({ loading: false, error: undefined, changePhoneNumberToken: res.changePhoneNumberToken, step: ResetPhoneNumberStep.ChangePhoneNumber }));
|
|
3994
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
3995
|
-
}
|
|
3996
|
-
catch (e) {
|
|
3997
|
-
yield put(actions.setResetPhoneNumberState({ loading: false, error: e.message }));
|
|
3998
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
3999
|
-
}
|
|
4000
|
-
}
|
|
4001
|
-
function* changePhoneNumber(_a) {
|
|
4002
|
-
var _b = _a.payload, { callback } = _b, body = __rest(_b, ["callback"]);
|
|
4003
|
-
yield put(actions.setResetPhoneNumberState({ loading: true }));
|
|
4004
|
-
try {
|
|
4005
|
-
const { onRedirectTo, routes } = yield select(({ auth: { onRedirectTo, routes } }) => ({ onRedirectTo, routes }));
|
|
4006
|
-
yield call(api.auth.changePhoneNumber, { phoneNumber: body.phoneNumber, changePhoneNumberToken: body.changePhoneNumberToken });
|
|
4007
|
-
yield put(actions.setLoginState({ step: LoginStep.loginWithSmsOtc }));
|
|
4008
|
-
yield put(actions.passwordlessPreLogin({
|
|
4009
|
-
type: AuthStrategyEnum.SmsCode,
|
|
4010
|
-
email: body.email,
|
|
4011
|
-
recaptchaToken: body.recaptchaToken,
|
|
4012
|
-
}));
|
|
4013
|
-
onRedirectTo(routes.loginUrl);
|
|
4014
|
-
yield put(actions.setResetPhoneNumberState({ loading: false }));
|
|
4015
|
-
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
4016
|
-
}
|
|
4017
|
-
catch (e) {
|
|
4018
|
-
yield put(actions.setResetPhoneNumberState({ loading: false, error: e.message }));
|
|
4019
|
-
callback === null || callback === void 0 ? void 0 : callback(null, e);
|
|
4020
|
-
}
|
|
4021
|
-
}
|
|
4022
|
-
function* resetPhoneNumberSagas() {
|
|
4023
|
-
yield takeLeading(actions.resetPhoneNumber, resetPhoneNumber);
|
|
4024
|
-
yield takeLeading(actions.verifyResetPhoneNumber, verifyResetPhoneNumber);
|
|
4025
|
-
yield takeLeading(actions.changePhoneNumber, changePhoneNumber);
|
|
4026
|
-
}
|
|
4027
|
-
|
|
4028
|
-
function* sagas() {
|
|
4029
|
-
yield all([
|
|
4030
|
-
call(loginSagas),
|
|
4031
|
-
call(activateSagas),
|
|
4032
|
-
call(acceptInvitationSagas),
|
|
4033
|
-
call(forgotPasswordSagas),
|
|
4034
|
-
call(resetPhoneNumberSagas),
|
|
4035
|
-
call(ssoSagas$1),
|
|
4036
|
-
call(ssoSagas),
|
|
4037
|
-
call(profileSagas),
|
|
4038
|
-
call(mfaSagas),
|
|
4039
|
-
call(teamSagas),
|
|
4040
|
-
call(socialLoginsSaga),
|
|
4041
|
-
call(signUpSaga),
|
|
4042
|
-
call(apiTokensSaga),
|
|
4043
|
-
call(securityPolicySagas),
|
|
4044
|
-
call(accountSettingsSaga),
|
|
4045
|
-
call(tenantsSagas),
|
|
4046
|
-
call(rolesSagas),
|
|
4047
|
-
]);
|
|
4048
|
-
}
|
|
4049
|
-
function* mockSagas() {
|
|
4050
|
-
yield all([
|
|
4051
|
-
call(loginSagasMock),
|
|
4052
|
-
// call(activateSagas),
|
|
4053
|
-
// call(acceptInvitationSagas),
|
|
4054
|
-
// call(forgotPasswordSagas),
|
|
4055
|
-
// call(socialLoginsSaga),
|
|
4056
|
-
// call(signUpSaga),
|
|
4057
|
-
call(ssoSagasMock),
|
|
4058
|
-
call(profileSagasMock),
|
|
4059
|
-
call(mfaSagasMock),
|
|
4060
|
-
call(teamSagasMock),
|
|
4061
|
-
call(apiTokensSagaMock),
|
|
4062
|
-
call(securityPolicySagasMock),
|
|
4063
|
-
call(accountSettingsSagaMock),
|
|
4064
|
-
call(tenantsSagasMock),
|
|
4065
|
-
]);
|
|
4066
|
-
}
|
|
4067
|
-
|
|
4068
|
-
// export store
|
|
4069
|
-
var authStore = {
|
|
4070
|
-
sagas,
|
|
4071
|
-
mockSagas,
|
|
4072
|
-
storeName: authStoreName,
|
|
4073
|
-
initialState,
|
|
4074
|
-
reducer,
|
|
4075
|
-
actions,
|
|
4076
|
-
};
|
|
4077
|
-
|
|
4078
|
-
export { AcceptInvitationStep, ActivateAccountStep, ApiStateKeys, AuthenticationTypes, ForgotPasswordStep, LoginFlow, LoginStep, MFAStep, QuickLoginStrategy, ResetPhoneNumberStep, SSOStateKeys, SamlVendors, SignUpStage, TeamStateKeys, UserVeirifedOriginTypes, actions$e as acceptInvitationActions, reducers$d as acceptInvitationReducers, acceptInvitationState, actions$3 as accountSettingsActions, reducers$2 as accountSettingsReducers, accountSettingsState, actions$f as activateAccountActions, reducers$e as activateAccountReducers, activateState, actions$5 as apiTokensActions, reducers$4 as apiTokensReducers, apiTokensState, actions as authActions, initialState as authInitialState, mockSagas as authMockSagas, reducer as authReducers, sagas as authSagas, authStore as default, actions$d as forgotPasswordActions, reducers$c as forgotPasswordReducers, forgotPasswordState, actions$g as loginActions, reducers$f as loginReducers, loginState, actions$9 as mfaActions, reducers$8 as mfaReducers, mfaState, actions$a as profileActions, reducers$9 as profileReducers, profileState, actions$c as resetPhoneNumberActions, reducers$b as resetPhoneNumberReducers, resetPhoneNumberState, actions$1 as rolesActions, reducers as rolesReducers, rolesState, actions$4 as securityPolicyActions, reducers$3 as securityPolicyReducers, securityPolicyState, actions$6 as signUpActions, reducers$5 as signUpReducers, signUpState, socialLoginState, actions$7 as socialLoginsActions, reducers$6 as socialLoginsReducer, actions$b as ssoActions, reducers$a as ssoReducers, ssoState, actions$8 as teamActions, reducers$7 as teamReducers, teamState, actions$2 as tenantsActions, reducers$1 as tenantsReducers, tenantsState };
|
|
1
|
+
import { reducer, actions } from './reducer';
|
|
2
|
+
import { mockSagas, sagas } from './saga';
|
|
3
|
+
import { authStoreName as storeName } from '../constants';
|
|
4
|
+
import { initialState } from './initialState';
|
|
5
|
+
export * from './interfaces';
|
|
6
|
+
export * from './LoginState/interfaces';
|
|
7
|
+
export * from './LoginState';
|
|
8
|
+
export * from './ActivateState/interfaces';
|
|
9
|
+
export * from './ActivateState';
|
|
10
|
+
export * from './AcceptInvitationState/interfaces';
|
|
11
|
+
export * from './AcceptInvitationState';
|
|
12
|
+
export * from './ForgotPasswordState/interfaces';
|
|
13
|
+
export * from './ForgotPasswordState';
|
|
14
|
+
export * from './ResetPhoneNumberState/interfaces';
|
|
15
|
+
export * from './ResetPhoneNumberState';
|
|
16
|
+
export * from './SSOState/interfaces';
|
|
17
|
+
export * from './SSOState';
|
|
18
|
+
export * from './MfaState/interfaces';
|
|
19
|
+
export * from './MfaState';
|
|
20
|
+
export * from './ProfileState/interfaces';
|
|
21
|
+
export * from './ProfileState';
|
|
22
|
+
export * from './TeamState/interfaces';
|
|
23
|
+
export * from './TeamState';
|
|
24
|
+
export * from './SocialLogins/interfaces';
|
|
25
|
+
export * from './SocialLogins';
|
|
26
|
+
export * from './SignUp/interfaces';
|
|
27
|
+
export * from './SignUp';
|
|
28
|
+
export * from './ApiTokensState/interfaces';
|
|
29
|
+
export * from './ApiTokensState';
|
|
30
|
+
export * from './SecurityPolicyState/interfaces';
|
|
31
|
+
export * from './SecurityPolicyState';
|
|
32
|
+
export * from './AccountSettingsState/interfaces';
|
|
33
|
+
export * from './AccountSettingsState';
|
|
34
|
+
export * from './TenantsState/interfaces';
|
|
35
|
+
export * from './TenantsState';
|
|
36
|
+
export * from './RolesState/interfaces';
|
|
37
|
+
export * from './RolesState';
|
|
38
|
+
export { sagas as authSagas, mockSagas as authMockSagas, reducer as authReducers, actions as authActions, initialState as authInitialState, storeName as authStoreName };
|
|
39
|
+
export default {
|
|
40
|
+
sagas,
|
|
41
|
+
mockSagas,
|
|
42
|
+
storeName,
|
|
43
|
+
initialState,
|
|
44
|
+
reducer,
|
|
45
|
+
actions
|
|
46
|
+
};
|