acsi-core 1.2.32 → 1.2.36
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/dist/containers/Login/apiClient/index.d.ts +5 -5
- package/dist/containers/Login/hooks/useLogin.d.ts +1 -1
- package/dist/index.js +61 -34
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +61 -34
- package/dist/index.modern.js.map +1 -1
- package/dist/services/accountService.d.ts +6 -6
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const getGoogleClientId: () => Promise<import("axios").AxiosResponse<any, any
|
|
2
|
-
export declare const apiLoginGoogle: (body: any) => Promise<import("axios").AxiosResponse<any, any
|
|
3
|
-
export declare const apiSendEmailCode: (body: any) => Promise<import("axios").AxiosResponse<any, any
|
|
4
|
-
export declare const apiCheckEmailCode: (params: any) => Promise<import("axios").AxiosResponse<any, any
|
|
5
|
-
export declare const apiGetImage: () => Promise<import("axios").AxiosResponse<any, any
|
|
1
|
+
export declare const getGoogleClientId: () => Promise<import("axios").AxiosResponse<any, any>>;
|
|
2
|
+
export declare const apiLoginGoogle: (body: any) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
3
|
+
export declare const apiSendEmailCode: (body: any) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
4
|
+
export declare const apiCheckEmailCode: (params: any) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
5
|
+
export declare const apiGetImage: () => Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -5,7 +5,7 @@ declare type LoginInfo = {
|
|
|
5
5
|
captcha: string;
|
|
6
6
|
rememberMe: boolean;
|
|
7
7
|
};
|
|
8
|
-
declare const useLogin: (
|
|
8
|
+
declare const useLogin: (onNavigate: any, trackEvent?: ((props: any) => void) | undefined) => {
|
|
9
9
|
defaultInfo: LoginInfo;
|
|
10
10
|
openLogin: boolean;
|
|
11
11
|
toggle: () => void;
|
package/dist/index.js
CHANGED
|
@@ -1729,7 +1729,7 @@ var apiUpload = axios.create({
|
|
|
1729
1729
|
if (imPersonate) {
|
|
1730
1730
|
config.headers.ImPersonate = imPersonate;
|
|
1731
1731
|
}
|
|
1732
|
-
var tenantId = localStorage.getItem(ORGANIZATION_TENANT);
|
|
1732
|
+
var tenantId = config.externalTenant || localStorage.getItem(ORGANIZATION_TENANT);
|
|
1733
1733
|
if (tenantId) {
|
|
1734
1734
|
config.headers["X-TenantID"] = tenantId;
|
|
1735
1735
|
}
|
|
@@ -1838,8 +1838,8 @@ var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
|
1838
1838
|
};
|
|
1839
1839
|
|
|
1840
1840
|
var BlockLogin = function BlockLogin(_ref) {
|
|
1841
|
-
var
|
|
1842
|
-
role = _ref
|
|
1841
|
+
var onNavigate = _ref.onNavigate,
|
|
1842
|
+
role = _ref.role,
|
|
1843
1843
|
hiddenSignup = _ref.hiddenSignup,
|
|
1844
1844
|
email = _ref.email,
|
|
1845
1845
|
setEmail = _ref.setEmail,
|
|
@@ -1919,7 +1919,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1919
1919
|
};
|
|
1920
1920
|
dispatch(setLoading(true));
|
|
1921
1921
|
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1922
|
-
var _authResult$data
|
|
1922
|
+
var _authResult$data;
|
|
1923
1923
|
if (((_authResult$data = authResult.data) === null || _authResult$data === void 0 ? void 0 : _authResult$data.id) == null) {
|
|
1924
1924
|
dispatch(setLoading(false));
|
|
1925
1925
|
alert("Please contact admin.");
|
|
@@ -1937,16 +1937,27 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1937
1937
|
timestamp: new Date().toISOString()
|
|
1938
1938
|
}
|
|
1939
1939
|
});
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1940
|
+
if (role === "LandingPage") {
|
|
1941
|
+
CookieService.setAuthCookie({
|
|
1942
|
+
token: tokenJWT,
|
|
1943
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
1944
|
+
});
|
|
1945
|
+
var getRedirectUrl = function getRedirectUrl(role) {
|
|
1946
|
+
switch (role) {
|
|
1947
|
+
case "Admin":
|
|
1948
|
+
return ADMIN_ORIGIN;
|
|
1949
|
+
case "Teacher":
|
|
1950
|
+
return TEACHER_ORIGIN;
|
|
1951
|
+
default:
|
|
1952
|
+
return role + "." + REQUEST_ORIGIN;
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
1956
|
+
window.location.href = redirectUrl + "/dashboard";
|
|
1957
|
+
dispatch(setLoading(false));
|
|
1948
1958
|
}
|
|
1949
|
-
|
|
1959
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
1960
|
+
onNavigate("/dashboard");
|
|
1950
1961
|
dispatch(setLoading(false));
|
|
1951
1962
|
});
|
|
1952
1963
|
}
|
|
@@ -1995,8 +2006,8 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1995
2006
|
};
|
|
1996
2007
|
dispatch(setLoading(true));
|
|
1997
2008
|
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1998
|
-
var _authResult$
|
|
1999
|
-
if (((_authResult$
|
|
2009
|
+
var _authResult$data2;
|
|
2010
|
+
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
2000
2011
|
dispatch(setLoading(false));
|
|
2001
2012
|
alert("Please contact admin.");
|
|
2002
2013
|
return;
|
|
@@ -2013,16 +2024,27 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
2013
2024
|
timestamp: new Date().toISOString()
|
|
2014
2025
|
}
|
|
2015
2026
|
});
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2027
|
+
if (role === "LandingPage") {
|
|
2028
|
+
CookieService.setAuthCookie({
|
|
2029
|
+
token: tokenJWT,
|
|
2030
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
2031
|
+
});
|
|
2032
|
+
var getRedirectUrl = function getRedirectUrl(role) {
|
|
2033
|
+
switch (role) {
|
|
2034
|
+
case "Admin":
|
|
2035
|
+
return ADMIN_ORIGIN;
|
|
2036
|
+
case "Teacher":
|
|
2037
|
+
return TEACHER_ORIGIN;
|
|
2038
|
+
default:
|
|
2039
|
+
return role + "." + REQUEST_ORIGIN;
|
|
2040
|
+
}
|
|
2041
|
+
};
|
|
2042
|
+
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
2043
|
+
window.location.href = redirectUrl + "/dashboard";
|
|
2044
|
+
dispatch(setLoading(false));
|
|
2024
2045
|
}
|
|
2025
|
-
|
|
2046
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
2047
|
+
onNavigate("/dashboard");
|
|
2026
2048
|
dispatch(setLoading(false));
|
|
2027
2049
|
});
|
|
2028
2050
|
}
|
|
@@ -2398,7 +2420,7 @@ var defaultInfo = {
|
|
|
2398
2420
|
rememberMe: false
|
|
2399
2421
|
};
|
|
2400
2422
|
var minutes = 15;
|
|
2401
|
-
var useLogin = function useLogin(
|
|
2423
|
+
var useLogin = function useLogin(onNavigate, trackEvent) {
|
|
2402
2424
|
var _useState = React.useState(false),
|
|
2403
2425
|
openLogin = _useState[0],
|
|
2404
2426
|
setOpenLogin = _useState[1];
|
|
@@ -2465,7 +2487,6 @@ var useLogin = function useLogin(_onNavigate, trackEvent) {
|
|
|
2465
2487
|
})).then(function (res) {
|
|
2466
2488
|
var data = res.data;
|
|
2467
2489
|
if (data.success) {
|
|
2468
|
-
var _data$data$roles;
|
|
2469
2490
|
localStorage.clear();
|
|
2470
2491
|
var tokenJWT = data.data.token;
|
|
2471
2492
|
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
@@ -2477,15 +2498,21 @@ var useLogin = function useLogin(_onNavigate, trackEvent) {
|
|
|
2477
2498
|
timestamp: new Date().toISOString()
|
|
2478
2499
|
}
|
|
2479
2500
|
});
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2501
|
+
var isRootDomain = window.location.hostname === REQUEST_ORIGIN || window.location.hostname === "www." + REQUEST_ORIGIN;
|
|
2502
|
+
if (isRootDomain) {
|
|
2503
|
+
var _data$data$roles;
|
|
2504
|
+
CookieService.setAuthCookie({
|
|
2505
|
+
token: tokenJWT,
|
|
2506
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
2507
|
+
});
|
|
2508
|
+
var domain = TEACHER_ORIGIN;
|
|
2509
|
+
if ((_data$data$roles = data.data.roles) !== null && _data$data$roles !== void 0 && _data$data$roles.includes("Admin")) {
|
|
2510
|
+
domain = ADMIN_ORIGIN;
|
|
2511
|
+
}
|
|
2512
|
+
window.location.href = domain + "/dashboard";
|
|
2513
|
+
} else {
|
|
2514
|
+
onNavigate("/dashboard");
|
|
2487
2515
|
}
|
|
2488
|
-
window.location.href = domain + "/dashboard";
|
|
2489
2516
|
} else {
|
|
2490
2517
|
reactToastify.toast.error("The code is not correct. Please check again.");
|
|
2491
2518
|
}
|