acsi-core 0.1.89 → 0.1.91
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/configs/constants.d.ts +26 -0
- package/dist/containers/Login/configs/default.d.ts +2 -1
- package/dist/index.css +16 -0
- package/dist/index.js +163 -13
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +164 -14
- package/dist/index.modern.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -0
- package/package.json +3 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LogLevel } from "@azure/msal-browser";
|
|
1
2
|
export declare enum AuthenticationMessage {
|
|
2
3
|
NotAllowedToRegister = "NotAllowedToRegister",
|
|
3
4
|
InvalidGoogleToken = "InvalidGoogleToken"
|
|
@@ -7,3 +8,28 @@ export declare enum Role {
|
|
|
7
8
|
Teacher = "Teacher",
|
|
8
9
|
Admin = "Admin"
|
|
9
10
|
}
|
|
11
|
+
export interface IInformationUser {
|
|
12
|
+
firstName: string;
|
|
13
|
+
lastName: string;
|
|
14
|
+
fullName: string;
|
|
15
|
+
imageUrl: string | null;
|
|
16
|
+
email: string;
|
|
17
|
+
accessToken: string;
|
|
18
|
+
googleId: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const msalConfig: (clientId: string, redirectUri: string) => {
|
|
21
|
+
auth: {
|
|
22
|
+
clientId: string;
|
|
23
|
+
authority: string;
|
|
24
|
+
redirectUri: string;
|
|
25
|
+
};
|
|
26
|
+
cache: {
|
|
27
|
+
cacheLocation: string;
|
|
28
|
+
storeAuthStateInCookie: boolean;
|
|
29
|
+
};
|
|
30
|
+
system: {
|
|
31
|
+
loggerOptions: {
|
|
32
|
+
loggerCallback: (level: LogLevel, message: string, containsPii: any) => void;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
package/dist/index.css
CHANGED
|
@@ -30,6 +30,22 @@
|
|
|
30
30
|
justify-content: center;
|
|
31
31
|
gap: 8px;
|
|
32
32
|
margin-bottom: 19px; }
|
|
33
|
+
._1KLz9 ._2Jo1o ._19ESb {
|
|
34
|
+
margin-bottom: 10px; }
|
|
35
|
+
._1KLz9 ._2Jo1o ._19ESb button {
|
|
36
|
+
width: 100%;
|
|
37
|
+
padding: 12px;
|
|
38
|
+
border-radius: 12px;
|
|
39
|
+
border: none;
|
|
40
|
+
background-color: transparent;
|
|
41
|
+
border: 1px solid #e6e6eb;
|
|
42
|
+
font-size: 16px;
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
color: #101129;
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
gap: 8px; }
|
|
33
49
|
._1KLz9 ._2Jo1o ._2e9xO {
|
|
34
50
|
font-size: 13px;
|
|
35
51
|
color: #c6c6cc;
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var ReactSelect = require('react-select');
|
|
|
13
13
|
var ReactSelect__default = _interopDefault(ReactSelect);
|
|
14
14
|
var Cookies = _interopDefault(require('js-cookie'));
|
|
15
15
|
var moment = _interopDefault(require('moment'));
|
|
16
|
+
var msalBrowser = require('@azure/msal-browser');
|
|
16
17
|
var reactToastify = require('react-toastify');
|
|
17
18
|
var reactGoogleLogin = require('@leecheuk/react-google-login');
|
|
18
19
|
var material = require('@mui/material');
|
|
@@ -46,6 +47,8 @@ var PUSHER_CONFIG = {
|
|
|
46
47
|
cluster: process.env.REACT_APP_PUSHER_CONFIG_CLUSTER || "",
|
|
47
48
|
key: process.env.REACT_APP_PUSHER_CONFIG_KEY || ""
|
|
48
49
|
};
|
|
50
|
+
var MICROSOFT_CLIENT_ID = process.env.REACT_APP_MICROSOFT_CLIENT_ID || "";
|
|
51
|
+
var MICROSOFT_URL_DIRECT = process.env.REACT_APP_MICROSOFT_URL_DIRECT || "";
|
|
49
52
|
var OPENSALT_BASE_URL = process.env.REACT_APP_OPENSALT || "";
|
|
50
53
|
var ACCESS_TOKEN = "ACCESS_TOKEN";
|
|
51
54
|
var AUTH_COOKIE = "auth";
|
|
@@ -75,7 +78,7 @@ var COLORS = {
|
|
|
75
78
|
var ORGANIZATION_TENANT = "ORGANIZATION_TENANT";
|
|
76
79
|
var ORGANIZATION_TEAM = "ORGANIZATION_TEAM";
|
|
77
80
|
|
|
78
|
-
var styleGlobal = {"signup_wrap":"_1KLz9","box-signin":"_2Jo1o","signin_title":"_3egBO","signup_link":"_1DoIT","google_button":"_34hK_","box-field":"_2e9xO","box-input":"_3zXRp","box-text":"_8NJga","box-button-email":"_21FPk","box-signin-container":"_1QERu","box-signin-text":"_2-znH","box-signin-logo":"_1aB2m","box-right":"_3qndF","image-slideshow":"_1aM7m","active":"_Vx1zf","box-right-body":"_JzdCr","box-right-footer":"_19aCA","pr-30":"_2HB5r","width-400":"_4ehXP"};
|
|
81
|
+
var styleGlobal = {"signup_wrap":"_1KLz9","box-signin":"_2Jo1o","signin_title":"_3egBO","signup_link":"_1DoIT","google_button":"_34hK_","microsoft_button":"_19ESb","box-field":"_2e9xO","box-input":"_3zXRp","box-text":"_8NJga","box-button-email":"_21FPk","box-signin-container":"_1QERu","box-signin-text":"_2-znH","box-signin-logo":"_1aB2m","box-right":"_3qndF","image-slideshow":"_1aM7m","active":"_Vx1zf","box-right-body":"_JzdCr","box-right-footer":"_19aCA","pr-30":"_2HB5r","width-400":"_4ehXP"};
|
|
79
82
|
|
|
80
83
|
// A type of promise-like that resolves synchronously and supports only one observer
|
|
81
84
|
|
|
@@ -1217,8 +1220,58 @@ var TypeLogin;
|
|
|
1217
1220
|
TypeLogin[TypeLogin["Google"] = 0] = "Google";
|
|
1218
1221
|
TypeLogin[TypeLogin["Email"] = 1] = "Email";
|
|
1219
1222
|
TypeLogin[TypeLogin["Impersonate"] = 2] = "Impersonate";
|
|
1223
|
+
TypeLogin[TypeLogin["Microsoft"] = 3] = "Microsoft";
|
|
1220
1224
|
})(TypeLogin || (TypeLogin = {}));
|
|
1221
1225
|
|
|
1226
|
+
var AuthenticationMessage;
|
|
1227
|
+
(function (AuthenticationMessage) {
|
|
1228
|
+
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
1229
|
+
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
1230
|
+
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
1231
|
+
(function (Role) {
|
|
1232
|
+
Role["Student"] = "Student";
|
|
1233
|
+
Role["Teacher"] = "Teacher";
|
|
1234
|
+
Role["Admin"] = "Admin";
|
|
1235
|
+
})(exports.Role || (exports.Role = {}));
|
|
1236
|
+
var msalConfig = function msalConfig(clientId, redirectUri) {
|
|
1237
|
+
return {
|
|
1238
|
+
auth: {
|
|
1239
|
+
clientId: clientId,
|
|
1240
|
+
authority: "https://login.microsoftonline.com/common",
|
|
1241
|
+
redirectUri: redirectUri
|
|
1242
|
+
},
|
|
1243
|
+
cache: {
|
|
1244
|
+
cacheLocation: "sessionStorage",
|
|
1245
|
+
storeAuthStateInCookie: false
|
|
1246
|
+
},
|
|
1247
|
+
system: {
|
|
1248
|
+
loggerOptions: {
|
|
1249
|
+
loggerCallback: function loggerCallback(level, message, containsPii) {
|
|
1250
|
+
if (containsPii) {
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
switch (level) {
|
|
1254
|
+
case msalBrowser.LogLevel.Error:
|
|
1255
|
+
console.error(message);
|
|
1256
|
+
return;
|
|
1257
|
+
case msalBrowser.LogLevel.Info:
|
|
1258
|
+
console.info(message);
|
|
1259
|
+
return;
|
|
1260
|
+
case msalBrowser.LogLevel.Verbose:
|
|
1261
|
+
console.debug(message);
|
|
1262
|
+
return;
|
|
1263
|
+
case msalBrowser.LogLevel.Warning:
|
|
1264
|
+
console.warn(message);
|
|
1265
|
+
return;
|
|
1266
|
+
default:
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1222
1275
|
var BlockLogin = function BlockLogin(_ref) {
|
|
1223
1276
|
var onNavigate = _ref.onNavigate,
|
|
1224
1277
|
role = _ref.role,
|
|
@@ -1249,6 +1302,9 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1249
1302
|
var _useState5 = React.useState(0),
|
|
1250
1303
|
currentImageIndex = _useState5[0],
|
|
1251
1304
|
setCurrentImageIndex = _useState5[1];
|
|
1305
|
+
var _useState6 = React.useState(),
|
|
1306
|
+
msalInstance = _useState6[0],
|
|
1307
|
+
setMsalInstance = _useState6[1];
|
|
1252
1308
|
var handleGetImage = function handleGetImage() {
|
|
1253
1309
|
try {
|
|
1254
1310
|
var _temp = _catch(function () {
|
|
@@ -1353,6 +1409,88 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1353
1409
|
return console.log(errorResponse);
|
|
1354
1410
|
}
|
|
1355
1411
|
});
|
|
1412
|
+
var fnLoginMicrosoft = function fnLoginMicrosoft() {
|
|
1413
|
+
try {
|
|
1414
|
+
if (!msalInstance) {
|
|
1415
|
+
console.error("MSAL instance not initialized");
|
|
1416
|
+
return Promise.resolve();
|
|
1417
|
+
}
|
|
1418
|
+
return Promise.resolve(_catch(function () {
|
|
1419
|
+
return Promise.resolve(msalInstance.initialize()).then(function () {
|
|
1420
|
+
var loginRequest = {
|
|
1421
|
+
scopes: ["openid", "profile", "email"]
|
|
1422
|
+
};
|
|
1423
|
+
return Promise.resolve(msalInstance.loginPopup(loginRequest)).then(function (response) {
|
|
1424
|
+
return function () {
|
|
1425
|
+
if (response && response.account) {
|
|
1426
|
+
var account = response.account;
|
|
1427
|
+
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
1428
|
+
var infoLogin = {
|
|
1429
|
+
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
1430
|
+
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
1431
|
+
fullName: fullName,
|
|
1432
|
+
imageUrl: "",
|
|
1433
|
+
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
1434
|
+
token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
|
|
1435
|
+
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
1436
|
+
role: role,
|
|
1437
|
+
type: TypeLogin.Microsoft
|
|
1438
|
+
};
|
|
1439
|
+
dispatch(setLoading(true));
|
|
1440
|
+
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1441
|
+
var _authResult$data2;
|
|
1442
|
+
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
1443
|
+
dispatch(setLoading(false));
|
|
1444
|
+
alert("Please contact admin.");
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
localStorage.clear();
|
|
1448
|
+
var tokenJWT = authResult.data.token;
|
|
1449
|
+
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
1450
|
+
eventName: exports.AmplitudeEvent.LOGIN,
|
|
1451
|
+
eventProperties: {
|
|
1452
|
+
email: email,
|
|
1453
|
+
login_method: 'google',
|
|
1454
|
+
user_role: authResult.data.role,
|
|
1455
|
+
success: true,
|
|
1456
|
+
timestamp: new Date().toISOString()
|
|
1457
|
+
}
|
|
1458
|
+
});
|
|
1459
|
+
if (role === "LandingPage") {
|
|
1460
|
+
CookieService.setAuthCookie({
|
|
1461
|
+
token: tokenJWT,
|
|
1462
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
1463
|
+
});
|
|
1464
|
+
var getRedirectUrl = function getRedirectUrl(role) {
|
|
1465
|
+
switch (role) {
|
|
1466
|
+
case "Admin":
|
|
1467
|
+
return ADMIN_ORIGIN;
|
|
1468
|
+
case "Teacher":
|
|
1469
|
+
return TEACHER_ORIGIN;
|
|
1470
|
+
default:
|
|
1471
|
+
return role + "." + REQUEST_ORIGIN;
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
1475
|
+
window.location.href = redirectUrl + "/dashboard";
|
|
1476
|
+
dispatch(setLoading(false));
|
|
1477
|
+
}
|
|
1478
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
1479
|
+
onNavigate("/dashboard");
|
|
1480
|
+
dispatch(setLoading(false));
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
}();
|
|
1484
|
+
});
|
|
1485
|
+
});
|
|
1486
|
+
}, function (error) {
|
|
1487
|
+
console.error("Microsoft login error:", error);
|
|
1488
|
+
alert("Microsoft login failed. Please try again.");
|
|
1489
|
+
}));
|
|
1490
|
+
} catch (e) {
|
|
1491
|
+
return Promise.reject(e);
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1356
1494
|
React__default.useEffect(function () {
|
|
1357
1495
|
return function () {
|
|
1358
1496
|
if (resendTimer) {
|
|
@@ -1417,6 +1555,18 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1417
1555
|
return clearInterval(interval);
|
|
1418
1556
|
};
|
|
1419
1557
|
}, [images.length]);
|
|
1558
|
+
var initInformationSSO = function initInformationSSO() {
|
|
1559
|
+
try {
|
|
1560
|
+
var _msalInstance = new msalBrowser.PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
|
|
1561
|
+
setMsalInstance(_msalInstance);
|
|
1562
|
+
return Promise.resolve();
|
|
1563
|
+
} catch (e) {
|
|
1564
|
+
return Promise.reject(e);
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
React.useEffect(function () {
|
|
1568
|
+
initInformationSSO();
|
|
1569
|
+
}, []);
|
|
1420
1570
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Row, {
|
|
1421
1571
|
style: {
|
|
1422
1572
|
height: "100%"
|
|
@@ -1460,7 +1610,18 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1460
1610
|
height: 24,
|
|
1461
1611
|
alt: "Google sign-in",
|
|
1462
1612
|
src: "/images/icons/Google__G__logo.png"
|
|
1463
|
-
}), "Sign in with Google")), React__default.createElement("
|
|
1613
|
+
}), "Sign in with Google")), React__default.createElement("div", {
|
|
1614
|
+
className: "" + styleGlobal["microsoft_button"]
|
|
1615
|
+
}, React__default.createElement("button", {
|
|
1616
|
+
onClick: function onClick() {
|
|
1617
|
+
return fnLoginMicrosoft();
|
|
1618
|
+
}
|
|
1619
|
+
}, React__default.createElement("img", {
|
|
1620
|
+
width: 24,
|
|
1621
|
+
height: 24,
|
|
1622
|
+
alt: "Google sign-in",
|
|
1623
|
+
src: "/images/Single-Sign-On-logo.png"
|
|
1624
|
+
}), "Sign in with Microsoft")), React__default.createElement("span", {
|
|
1464
1625
|
className: "" + styleGlobal["box-field"]
|
|
1465
1626
|
}, "OR"), React__default.createElement("div", {
|
|
1466
1627
|
className: "" + styleGlobal["box-input"]
|
|
@@ -2290,17 +2451,6 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
|
2290
2451
|
}, title)), children);
|
|
2291
2452
|
};
|
|
2292
2453
|
|
|
2293
|
-
var AuthenticationMessage;
|
|
2294
|
-
(function (AuthenticationMessage) {
|
|
2295
|
-
AuthenticationMessage["NotAllowedToRegister"] = "NotAllowedToRegister";
|
|
2296
|
-
AuthenticationMessage["InvalidGoogleToken"] = "InvalidGoogleToken";
|
|
2297
|
-
})(AuthenticationMessage || (AuthenticationMessage = {}));
|
|
2298
|
-
(function (Role) {
|
|
2299
|
-
Role["Student"] = "Student";
|
|
2300
|
-
Role["Teacher"] = "Teacher";
|
|
2301
|
-
Role["Admin"] = "Admin";
|
|
2302
|
-
})(exports.Role || (exports.Role = {}));
|
|
2303
|
-
|
|
2304
2454
|
var CustomPagination = function CustomPagination(_ref) {
|
|
2305
2455
|
var currentPage = _ref.currentPage,
|
|
2306
2456
|
totalPage = _ref.totalPage,
|