acsi-core 0.1.89 → 0.1.90
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 +174 -13
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +175 -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_MICROSOFT_CLIENT_ID || "";
|
|
51
|
+
var MICROSOFT_URL_DIRECT = process.env.REACT_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,92 @@ 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
|
+
console.log("MSAL instance initialized:", msalInstance);
|
|
1421
|
+
var loginRequest = {
|
|
1422
|
+
scopes: ["openid", "profile", "email"]
|
|
1423
|
+
};
|
|
1424
|
+
return Promise.resolve(msalInstance.loginPopup(loginRequest)).then(function (response) {
|
|
1425
|
+
console.log("Login response:", response);
|
|
1426
|
+
return function () {
|
|
1427
|
+
if (response && response.account) {
|
|
1428
|
+
var account = response.account;
|
|
1429
|
+
console.log("User account:", account);
|
|
1430
|
+
var fullName = (account === null || account === void 0 ? void 0 : account.name) || "";
|
|
1431
|
+
var infoLogin = {
|
|
1432
|
+
firstName: fullName.split(' ').slice(0, -1).join(' '),
|
|
1433
|
+
lastName: fullName.split(' ').slice(-1).join(' '),
|
|
1434
|
+
fullName: fullName,
|
|
1435
|
+
imageUrl: "",
|
|
1436
|
+
email: (account === null || account === void 0 ? void 0 : account.username) || "",
|
|
1437
|
+
token: (response === null || response === void 0 ? void 0 : response.accessToken) || "",
|
|
1438
|
+
googleId: (account === null || account === void 0 ? void 0 : account.homeAccountId) || "",
|
|
1439
|
+
role: role,
|
|
1440
|
+
type: TypeLogin.Microsoft
|
|
1441
|
+
};
|
|
1442
|
+
dispatch(setLoading(true));
|
|
1443
|
+
return Promise.resolve(apiLoginGoogle(infoLogin)).then(function (authResult) {
|
|
1444
|
+
var _authResult$data2;
|
|
1445
|
+
if (((_authResult$data2 = authResult.data) === null || _authResult$data2 === void 0 ? void 0 : _authResult$data2.id) == null) {
|
|
1446
|
+
dispatch(setLoading(false));
|
|
1447
|
+
alert("Please contact admin.");
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
localStorage.clear();
|
|
1451
|
+
var tokenJWT = authResult.data.token;
|
|
1452
|
+
trackEvent === null || trackEvent === void 0 ? void 0 : trackEvent({
|
|
1453
|
+
eventName: exports.AmplitudeEvent.LOGIN,
|
|
1454
|
+
eventProperties: {
|
|
1455
|
+
email: email,
|
|
1456
|
+
login_method: 'google',
|
|
1457
|
+
user_role: authResult.data.role,
|
|
1458
|
+
success: true,
|
|
1459
|
+
timestamp: new Date().toISOString()
|
|
1460
|
+
}
|
|
1461
|
+
});
|
|
1462
|
+
console.log("Login info:", infoLogin);
|
|
1463
|
+
if (role === "LandingPage") {
|
|
1464
|
+
CookieService.setAuthCookie({
|
|
1465
|
+
token: tokenJWT,
|
|
1466
|
+
expiresAt: Date.now() + 24 * 60 * 60 * 1000
|
|
1467
|
+
});
|
|
1468
|
+
var getRedirectUrl = function getRedirectUrl(role) {
|
|
1469
|
+
switch (role) {
|
|
1470
|
+
case "Admin":
|
|
1471
|
+
return ADMIN_ORIGIN;
|
|
1472
|
+
case "Teacher":
|
|
1473
|
+
return TEACHER_ORIGIN;
|
|
1474
|
+
default:
|
|
1475
|
+
return role + "." + REQUEST_ORIGIN;
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
var redirectUrl = getRedirectUrl(authResult.data.role);
|
|
1479
|
+
window.location.href = redirectUrl + "/dashboard";
|
|
1480
|
+
dispatch(setLoading(false));
|
|
1481
|
+
}
|
|
1482
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
|
1483
|
+
onNavigate("/dashboard");
|
|
1484
|
+
dispatch(setLoading(false));
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
}();
|
|
1488
|
+
});
|
|
1489
|
+
});
|
|
1490
|
+
}, function (error) {
|
|
1491
|
+
console.error("Microsoft login error:", error);
|
|
1492
|
+
alert("Microsoft login failed. Please try again.");
|
|
1493
|
+
}));
|
|
1494
|
+
} catch (e) {
|
|
1495
|
+
return Promise.reject(e);
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1356
1498
|
React__default.useEffect(function () {
|
|
1357
1499
|
return function () {
|
|
1358
1500
|
if (resendTimer) {
|
|
@@ -1417,6 +1559,25 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1417
1559
|
return clearInterval(interval);
|
|
1418
1560
|
};
|
|
1419
1561
|
}, [images.length]);
|
|
1562
|
+
var initInformationSSO = function initInformationSSO() {
|
|
1563
|
+
try {
|
|
1564
|
+
console.log("Initializing Microsoft SSO with client ID:", MICROSOFT_CLIENT_ID, "and redirect URL:", MICROSOFT_URL_DIRECT);
|
|
1565
|
+
var _msalInstance = new msalBrowser.PublicClientApplication(msalConfig(MICROSOFT_CLIENT_ID, MICROSOFT_URL_DIRECT));
|
|
1566
|
+
console.log({
|
|
1567
|
+
msalInstance: _msalInstance
|
|
1568
|
+
});
|
|
1569
|
+
setMsalInstance(_msalInstance);
|
|
1570
|
+
return Promise.resolve();
|
|
1571
|
+
} catch (e) {
|
|
1572
|
+
return Promise.reject(e);
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
React.useEffect(function () {
|
|
1576
|
+
console.log({
|
|
1577
|
+
TEACHER_ORIGIN: TEACHER_ORIGIN
|
|
1578
|
+
});
|
|
1579
|
+
initInformationSSO();
|
|
1580
|
+
}, []);
|
|
1420
1581
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Row, {
|
|
1421
1582
|
style: {
|
|
1422
1583
|
height: "100%"
|
|
@@ -1460,7 +1621,18 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
|
1460
1621
|
height: 24,
|
|
1461
1622
|
alt: "Google sign-in",
|
|
1462
1623
|
src: "/images/icons/Google__G__logo.png"
|
|
1463
|
-
}), "Sign in with Google")), React__default.createElement("
|
|
1624
|
+
}), "Sign in with Google")), React__default.createElement("div", {
|
|
1625
|
+
className: "" + styleGlobal["microsoft_button"]
|
|
1626
|
+
}, React__default.createElement("button", {
|
|
1627
|
+
onClick: function onClick() {
|
|
1628
|
+
return fnLoginMicrosoft();
|
|
1629
|
+
}
|
|
1630
|
+
}, React__default.createElement("img", {
|
|
1631
|
+
width: 24,
|
|
1632
|
+
height: 24,
|
|
1633
|
+
alt: "Google sign-in",
|
|
1634
|
+
src: "/images/Single-Sign-On-logo.png"
|
|
1635
|
+
}), "Sign in with Microsoft")), React__default.createElement("span", {
|
|
1464
1636
|
className: "" + styleGlobal["box-field"]
|
|
1465
1637
|
}, "OR"), React__default.createElement("div", {
|
|
1466
1638
|
className: "" + styleGlobal["box-input"]
|
|
@@ -2290,17 +2462,6 @@ var CommonDialog = function CommonDialog(_ref) {
|
|
|
2290
2462
|
}, title)), children);
|
|
2291
2463
|
};
|
|
2292
2464
|
|
|
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
2465
|
var CustomPagination = function CustomPagination(_ref) {
|
|
2305
2466
|
var currentPage = _ref.currentPage,
|
|
2306
2467
|
totalPage = _ref.totalPage,
|