mario-core 2.9.199-plp → 2.9.200-plp

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.
@@ -0,0 +1,38 @@
1
+ import { LogLevel } from "@azure/msal-browser";
2
+ /**
3
+ * Configuration object to be passed to MSAL instance on creation.
4
+ * For a full list of MSAL.js configuration parameters, visit:
5
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/configuration.md
6
+ */
7
+ export declare const msalConfig: {
8
+ auth: {
9
+ clientId: string;
10
+ authority: string;
11
+ redirectUri: string;
12
+ };
13
+ cache: {
14
+ cacheLocation: string;
15
+ storeAuthStateInCookie: boolean;
16
+ };
17
+ system: {
18
+ loggerOptions: {
19
+ loggerCallback: (level: LogLevel, message: string, containsPii: any) => void;
20
+ };
21
+ };
22
+ };
23
+ /**
24
+ * Scopes you add here will be prompted for user consent during sign-in.
25
+ * By default, MSAL.js will add OIDC scopes (openid, profile, email) to any login request.
26
+ * For more information about OIDC scopes, visit:
27
+ * https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#openid-connect-scopes
28
+ */
29
+ export declare const loginRequest: {
30
+ scopes: string[];
31
+ };
32
+ /**
33
+ * Add here the scopes to request when obtaining an access token for MS Graph API. For more information, see:
34
+ * https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/resources-and-scopes.md
35
+ */
36
+ export declare const graphConfig: {
37
+ graphMeEndpoint: string;
38
+ };
@@ -5,3 +5,17 @@ export interface ICreatePassword {
5
5
  userId: string;
6
6
  token: string;
7
7
  }
8
+ export declare enum TypeLogin {
9
+ Google = 0,
10
+ ClassLink = 1,
11
+ MicrosoftSSO = 2
12
+ }
13
+ export interface IInformationUser {
14
+ firstName: string;
15
+ lastName: string;
16
+ fullName: string;
17
+ imageUrl: string | null;
18
+ email: string;
19
+ accessToken: string;
20
+ googleId: string;
21
+ }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { TypeLogin } from "../constant/types";
2
3
  declare type LoginInfo = {
3
4
  email: string;
4
5
  password: string;
@@ -12,16 +13,15 @@ declare const useLogin: () => {
12
13
  toggle: () => void;
13
14
  isShowPassword: boolean;
14
15
  setIsShowPassword: import("react").Dispatch<import("react").SetStateAction<boolean>>;
15
- fnIsCheckLogin: (data: any, token: string, clickHandler: any) => Promise<void>;
16
- isLoginGoogle: boolean;
16
+ fnIsCheckLogin: (type: TypeLogin, data: any, token: string, clickHandler?: any) => Promise<void>;
17
+ isLoginGoogle: any;
17
18
  infoUser: any;
18
- setInfoUser: import("react").Dispatch<any>;
19
19
  submitLogin: (teacherId: number, clickHandler: any) => Promise<void>;
20
- setIsLoginGoogle: import("react").Dispatch<import("react").SetStateAction<boolean>>;
21
20
  googleClientId: string;
22
21
  googleRecaptchaId: string;
23
22
  handleCancelModelAssign: () => void;
24
23
  openModelAssign: boolean;
25
24
  handleAssignTeacherByCode: (teacherCode: string, setIsError: Function) => Promise<void>;
25
+ fnLoginSSO: (clickHandler?: any) => Promise<void>;
26
26
  };
27
27
  export default useLogin;
@@ -6,7 +6,6 @@ interface Props {
6
6
  onSubmit: any;
7
7
  token: string;
8
8
  email: string;
9
- setOpenModal: any;
10
9
  }
11
10
  declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<unknown>>;
12
11
  export default _default;
package/dist/index.css CHANGED
@@ -712,6 +712,17 @@
712
712
  font-size: 20px;
713
713
  padding: 10px 20px; }
714
714
 
715
+ ._DrSlA {
716
+ text-align: center;
717
+ background: #e5e5e5;
718
+ font-size: 15px;
719
+ color: #ad9292;
720
+ border-radius: 8px;
721
+ cursor: pointer; }
722
+ ._DrSlA img {
723
+ width: 65px;
724
+ height: auto; }
725
+
715
726
  ._297lu {
716
727
  width: 100%;
717
728
  height: 100%; }
package/dist/index.js CHANGED
@@ -9,9 +9,10 @@ var React = require('react');
9
9
  var React__default = _interopDefault(React);
10
10
  var reactstrap = require('reactstrap');
11
11
  var reactRouterDom = require('react-router-dom');
12
+ var reactRedux = require('react-redux');
12
13
  var formik = require('formik');
13
14
  var yup = require('yup');
14
- var reactRedux = require('react-redux');
15
+ var msalBrowser = require('@azure/msal-browser');
15
16
  var toolkit = require('@reduxjs/toolkit');
16
17
  var axios = _interopDefault(require('axios'));
17
18
  var amplitude = _interopDefault(require('amplitude-js'));
@@ -12596,7 +12597,7 @@ function _catch(body, recover) {
12596
12597
  return result;
12597
12598
  }
12598
12599
 
12599
- var styles = {"btn-login-google":"_2HqmH","notification-count":"_2sew7","text-introduction":"_3OgWF","btn-trans-border":"_r9cAh","contact":"_NszFe","learn-more":"_MDjzH","title-quote":"_1Swkw","descriptions-quote":"_gi8vj","box-login":"_38Lo1","block-verification":"_1OzGy","block-login":"_wWIyO","title-login":"_3nuns","title-forgot-password":"_21qb6","btn-close":"_NhW9l","btn-login":"_3IL10","digital-privacy-icon":"_141p1","return-to-login":"_Ce3Kg","recover-account":"_2t6d9","link-to-login":"_3bDsd","remember":"_11FZt","term-and-conditions":"_3LXoI","descriptions-forgot-pass":"_PMcjT","content-icon":"_2rZY6","descriptions-icon":"_3SOdX","title-icon":"_y9lM2","nav-home":"_1TT1q","box-introduction":"_32V6L","icon":"_20YJX","form-user-name":"_39BJD","input":"_ozRAq","checkbox-remember":"_2K9b2","btn-rounder":"_2VvIr","btn-active":"_2A0HF","block-reset-password":"_23Sua","block-forgot-pass":"_3CWP6","page-not-login":"_3Wmco","content-quote":"_13Rk0","home-page":"_o6HKW","bg-animate":"_30npl","active":"_3oAH-","show":"_16rY4","fade-in":"_26nbh","behind":"_3A7Vv","login":"_F-hjL","login-content":"_149oA","logo-home":"_24U3W","img-box":"_2v-L_","img-login":"_3ncTL","img-login-rectangle":"_2kOvJ","c-main":"_39l0X","container-fluid":"_1BMwK","input-file-label":"_1XNpH","delete-avatar-button":"_1z5h9","header-logo":"_Gewcf","box-sidebar":"_2vcmv","sidebar-logo":"_1hXpy","sidebar-nav-links":"_3vb3s","c-active":"_36jSM","sidebar-nav-links-hover":"_DNrus","box-sidebar-header":"_3NEZj","box-logout":"_1wUDG","sidebar-btn-minimized":"_1S7Px","sidebar-minimized-logo":"_3846X","sidebar-logout":"_2P85D","nav-mobile":"_1qjbW","filter-media-file":"_1I62C","div":"_3cLcM","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","logout":"_1_9tV","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi","popover__sort__item":"_1ocBa","popover__sort__item--active":"_18NhM","popover__search__icon":"_2bquW","popover__search__input":"_3A4G4","popover__options":"_1MsEW","button-export":"_2rTzM","button-content":"_18y0w","button-icon":"_3cZAT","hide-in-mobile":"_1INnO","hamburger-menu":"_2yRc8","box-content-home-page":"_ABUIP","collapse-box":"_WX97m","hide-in-desktop":"_2LIqK","control-input":"_2Zz97","custom-control":"_3-yp5","item-select-role":"_1KcY7","item-role-active":"_dOVso","model-switch-roles":"_3ZqxI","title":"_g-p72"};
12600
+ var styles = {"btn-login-google":"_2HqmH","notification-count":"_2sew7","text-introduction":"_3OgWF","btn-trans-border":"_r9cAh","contact":"_NszFe","learn-more":"_MDjzH","title-quote":"_1Swkw","descriptions-quote":"_gi8vj","box-login":"_38Lo1","block-verification":"_1OzGy","block-login":"_wWIyO","title-login":"_3nuns","title-forgot-password":"_21qb6","btn-close":"_NhW9l","btn-login":"_3IL10","digital-privacy-icon":"_141p1","return-to-login":"_Ce3Kg","recover-account":"_2t6d9","link-to-login":"_3bDsd","remember":"_11FZt","term-and-conditions":"_3LXoI","descriptions-forgot-pass":"_PMcjT","content-icon":"_2rZY6","descriptions-icon":"_3SOdX","title-icon":"_y9lM2","nav-home":"_1TT1q","box-introduction":"_32V6L","icon":"_20YJX","form-user-name":"_39BJD","input":"_ozRAq","checkbox-remember":"_2K9b2","btn-rounder":"_2VvIr","btn-active":"_2A0HF","block-reset-password":"_23Sua","block-forgot-pass":"_3CWP6","page-not-login":"_3Wmco","content-quote":"_13Rk0","home-page":"_o6HKW","bg-animate":"_30npl","active":"_3oAH-","show":"_16rY4","fade-in":"_26nbh","behind":"_3A7Vv","login":"_F-hjL","login-content":"_149oA","logo-home":"_24U3W","img-box":"_2v-L_","img-login":"_3ncTL","img-login-rectangle":"_2kOvJ","c-main":"_39l0X","container-fluid":"_1BMwK","input-file-label":"_1XNpH","delete-avatar-button":"_1z5h9","header-logo":"_Gewcf","box-sidebar":"_2vcmv","sidebar-logo":"_1hXpy","sidebar-nav-links":"_3vb3s","c-active":"_36jSM","sidebar-nav-links-hover":"_DNrus","box-sidebar-header":"_3NEZj","box-logout":"_1wUDG","sidebar-btn-minimized":"_1S7Px","sidebar-minimized-logo":"_3846X","sidebar-logout":"_2P85D","nav-mobile":"_1qjbW","filter-media-file":"_1I62C","div":"_3cLcM","dropdown-menu":"_1krbH","header-avatar":"_RQaHE","dropdown-menu-flag":"_XK8oS","dropdown-content":"_3ys4W","dropdown-change":"_ToOW_","item-address":"_3sQlR","item-logout":"_3bqSM","title-address":"_1jgSI","img-avatar":"_35Ttz","item-contact":"_1wc7o","logout":"_1_9tV","content-text":"_3S4f2","dropdown-content-language":"_3ajui","dropdown-item-language":"_3Y_y4","dropdown-item-language-active":"_CzNMi","popover__sort__item":"_1ocBa","popover__sort__item--active":"_18NhM","popover__search__icon":"_2bquW","popover__search__input":"_3A4G4","popover__options":"_1MsEW","button-export":"_2rTzM","button-content":"_18y0w","button-icon":"_3cZAT","hide-in-mobile":"_1INnO","hamburger-menu":"_2yRc8","box-content-home-page":"_ABUIP","collapse-box":"_WX97m","hide-in-desktop":"_2LIqK","control-input":"_2Zz97","custom-control":"_3-yp5","item-select-role":"_1KcY7","item-role-active":"_dOVso","model-switch-roles":"_3ZqxI","title":"_g-p72","btn-login-with-sso":"_DrSlA"};
12600
12601
 
12601
12602
  var style = {
12602
12603
  fontSize: "0.85rem"
@@ -29946,6 +29947,8 @@ var setModal = toolkit.createAction("common/setModal");
29946
29947
  var setUser = toolkit.createAction("common/setUser");
29947
29948
  var setSidebar = toolkit.createAction("common/setSidebar");
29948
29949
  var setAlert = toolkit.createAction("common/setAlert");
29950
+ var setIsLoginGoogle = toolkit.createAction("common/setIsLoginGoogle");
29951
+ var setInforUserGoogle = toolkit.createAction("common/setInforUserGoogle");
29949
29952
  var reset = toolkit.createAction("common/reset");
29950
29953
  var showMenuBar = toolkit.createAction("common/showMenuBar");
29951
29954
  var showFontSize = toolkit.createAction("common/showFontSize");
@@ -30077,8 +30080,12 @@ var checkResetToken = function checkResetToken(token, key) {
30077
30080
  var resetPassword = function resetPassword(data) {
30078
30081
  return api.post(ACCOUNT_URL + "/resetpassword", data);
30079
30082
  };
30080
- var checkUserGoogle = function checkUserGoogle(body) {
30081
- return api.post(USER_URL + "/check-user", body);
30083
+ var checkUserGoogle = function checkUserGoogle(type, body) {
30084
+ return api.post(USER_URL + "/check-user", body, {
30085
+ params: {
30086
+ type: type
30087
+ }
30088
+ });
30082
30089
  };
30083
30090
  var getAllLoginTeacher = function getAllLoginTeacher(param) {
30084
30091
  return api.get(TEACHER_URL + "/get-teacher-login", {
@@ -30108,6 +30115,56 @@ var getSchoolSettings = function getSchoolSettings() {
30108
30115
  return api.get(SCHOOL_URL + "/settings");
30109
30116
  };
30110
30117
 
30118
+ var TypeLogin;
30119
+
30120
+ (function (TypeLogin) {
30121
+ TypeLogin[TypeLogin["Google"] = 0] = "Google";
30122
+ TypeLogin[TypeLogin["ClassLink"] = 1] = "ClassLink";
30123
+ TypeLogin[TypeLogin["MicrosoftSSO"] = 2] = "MicrosoftSSO";
30124
+ })(TypeLogin || (TypeLogin = {}));
30125
+
30126
+ var msalConfig = {
30127
+ auth: {
30128
+ clientId: "90c6897c-f17b-475e-a7a8-9a19651e0060",
30129
+ authority: "https://login.microsoftonline.com/common",
30130
+ redirectUri: window.location.origin + "/login"
30131
+ },
30132
+ cache: {
30133
+ cacheLocation: "sessionStorage",
30134
+ storeAuthStateInCookie: false
30135
+ },
30136
+ system: {
30137
+ loggerOptions: {
30138
+ loggerCallback: function loggerCallback(level, message, containsPii) {
30139
+ if (containsPii) {
30140
+ return;
30141
+ }
30142
+
30143
+ switch (level) {
30144
+ case msalBrowser.LogLevel.Error:
30145
+ console.error(message);
30146
+ return;
30147
+
30148
+ case msalBrowser.LogLevel.Info:
30149
+ console.info(message);
30150
+ return;
30151
+
30152
+ case msalBrowser.LogLevel.Verbose:
30153
+ console.debug(message);
30154
+ return;
30155
+
30156
+ case msalBrowser.LogLevel.Warning:
30157
+ console.warn(message);
30158
+ return;
30159
+
30160
+ default:
30161
+ return;
30162
+ }
30163
+ }
30164
+ }
30165
+ }
30166
+ };
30167
+
30111
30168
  var defaultInfo = {
30112
30169
  email: "",
30113
30170
  password: "",
@@ -30130,37 +30187,40 @@ var useLogin = function useLogin() {
30130
30187
  openLogin = _useState[0],
30131
30188
  setOpenLogin = _useState[1];
30132
30189
 
30133
- var _useState2 = React.useState(false),
30134
- isLoginGoogle = _useState2[0],
30135
- setIsLoginGoogle = _useState2[1];
30136
-
30137
- var _useState3 = React.useState(""),
30138
- googleClientId = _useState3[0],
30139
- setGoogleClientId = _useState3[1];
30190
+ var isLoginGoogle = reactRedux.useSelector(function (state) {
30191
+ return state.common.isLoginGoogle;
30192
+ });
30140
30193
 
30141
- var _useState4 = React.useState(""),
30142
- googleRecaptchaId = _useState4[0],
30143
- setGoogleRecaptchaId = _useState4[1];
30194
+ var _useState2 = React.useState(""),
30195
+ googleClientId = _useState2[0],
30196
+ setGoogleClientId = _useState2[1];
30144
30197
 
30145
- var _useState5 = React.useState(),
30146
- infoUser = _useState5[0],
30147
- setInfoUser = _useState5[1];
30198
+ var _useState3 = React.useState(""),
30199
+ googleRecaptchaId = _useState3[0],
30200
+ setGoogleRecaptchaId = _useState3[1];
30148
30201
 
30202
+ var infoUser = reactRedux.useSelector(function (state) {
30203
+ return state.common.inforUserGoogle;
30204
+ });
30149
30205
  var params = new URLSearchParams(location.search);
30150
30206
  var loginClassLink = params.get("type") === "classlink";
30151
30207
  var tokenClassLink = params.get("token");
30152
30208
 
30153
- var _useState6 = React.useState(false),
30154
- openModelAssign = _useState6[0],
30155
- setOpenModelAssign = _useState6[1];
30209
+ var _useState4 = React.useState(false),
30210
+ openModelAssign = _useState4[0],
30211
+ setOpenModelAssign = _useState4[1];
30212
+
30213
+ var _useState5 = React.useState(),
30214
+ msalInstance = _useState5[0],
30215
+ setMsalInstance = _useState5[1];
30156
30216
 
30157
30217
  var toggle = React.useCallback(function () {
30158
30218
  setOpenLogin(!openLogin);
30159
30219
  }, [openLogin]);
30160
30220
 
30161
- var _useState7 = React.useState(false),
30162
- isShowPassword = _useState7[0],
30163
- setIsShowPassword = _useState7[1];
30221
+ var _useState6 = React.useState(false),
30222
+ isShowPassword = _useState6[0],
30223
+ setIsShowPassword = _useState6[1];
30164
30224
 
30165
30225
  React.useEffect(function () {
30166
30226
  document.title = TITLE;
@@ -30425,39 +30485,50 @@ var useLogin = function useLogin() {
30425
30485
  }
30426
30486
  };
30427
30487
 
30428
- var fnIsCheckLogin = React.useCallback(function (data, token, clickHandler) {
30488
+ var fnIsCheckLogin = React.useCallback(function (type, data, token, clickHandler) {
30429
30489
  try {
30430
- var _temp29 = function _temp29() {
30490
+ var _temp31 = function _temp31() {
30431
30491
  dispatch(setLoading(false));
30432
30492
  };
30433
30493
 
30434
30494
  dispatch(setLoading(true));
30435
30495
 
30436
- var _temp30 = _catch(function () {
30437
- return Promise.resolve(checkUserGoogle(data)).then(function (res) {
30496
+ var _temp32 = _catch(function () {
30497
+ return Promise.resolve(checkUserGoogle(type, data)).then(function (res) {
30438
30498
  var checkUser = res.data;
30439
30499
 
30440
- var _temp26 = function () {
30500
+ var _temp28 = function () {
30441
30501
  if (checkUser) {
30442
- return Promise.resolve(clickHandler()).then(function (clickHandlerRes) {
30443
- var dataUser = {
30444
- email: data.email,
30445
- captcha: clickHandlerRes,
30446
- isLoginGoogle: true,
30447
- rememberMe: false,
30448
- password: "default",
30449
- accessToken: token
30450
- };
30451
- return Promise.resolve(userLogin(dataUser)).then(function () {
30452
- setIsLoginGoogle(false);
30502
+ var _temp33 = function _temp33() {
30503
+ return Promise.resolve(userLogin(_dataUser)).then(function () {
30504
+ dispatch(setIsLoginGoogle(false));
30453
30505
  });
30454
- });
30506
+ };
30507
+
30508
+ var _dataUser = {
30509
+ email: data.email,
30510
+ isLoginGoogle: true,
30511
+ rememberMe: false,
30512
+ password: "default",
30513
+ accessToken: token,
30514
+ captcha: ""
30515
+ };
30516
+
30517
+ var _temp34 = function () {
30518
+ if (clickHandler != null) {
30519
+ return Promise.resolve(clickHandler()).then(function (clickHandlerRes) {
30520
+ _dataUser.captcha = clickHandlerRes;
30521
+ });
30522
+ }
30523
+ }();
30524
+
30525
+ return _temp34 && _temp34.then ? _temp34.then(_temp33) : _temp33(_temp34);
30455
30526
  } else {
30456
- setIsLoginGoogle(true);
30527
+ dispatch(setIsLoginGoogle(true));
30457
30528
  }
30458
30529
  }();
30459
30530
 
30460
- if (_temp26 && _temp26.then) return _temp26.then(function () {});
30531
+ if (_temp28 && _temp28.then) return _temp28.then(function () {});
30461
30532
  });
30462
30533
  }, function (err) {
30463
30534
  var _err$response6, _err$response6$data;
@@ -30468,7 +30539,7 @@ var useLogin = function useLogin() {
30468
30539
  }));
30469
30540
  });
30470
30541
 
30471
- return Promise.resolve(_temp30 && _temp30.then ? _temp30.then(_temp29) : _temp29(_temp30));
30542
+ return Promise.resolve(_temp32 && _temp32.then ? _temp32.then(_temp31) : _temp31(_temp32));
30472
30543
  } catch (e) {
30473
30544
  return Promise.reject(e);
30474
30545
  }
@@ -30476,14 +30547,14 @@ var useLogin = function useLogin() {
30476
30547
 
30477
30548
  var submitLogin = function submitLogin(teacherId, clickHandler) {
30478
30549
  try {
30479
- var _temp34 = function _temp34() {
30480
- setIsLoginGoogle(false);
30550
+ var _temp38 = function _temp38() {
30551
+ dispatch(setIsLoginGoogle(false));
30481
30552
  dispatch(setLoading(false));
30482
30553
  };
30483
30554
 
30484
30555
  dispatch(setLoading(true));
30485
30556
 
30486
- var _temp35 = _catch(function () {
30557
+ var _temp39 = _catch(function () {
30487
30558
  var data = {
30488
30559
  firstName: infoUser.firstName,
30489
30560
  lastName: infoUser.lastName,
@@ -30494,7 +30565,7 @@ var useLogin = function useLogin() {
30494
30565
  teacherId: teacherId
30495
30566
  };
30496
30567
  return Promise.resolve(registerUserStudent(data)).then(function (res) {
30497
- var _temp31 = function () {
30568
+ var _temp35 = function () {
30498
30569
  if (res.data) {
30499
30570
  return Promise.resolve(clickHandler()).then(function (clickHandlerRes) {
30500
30571
  var dataLogin = {
@@ -30505,7 +30576,7 @@ var useLogin = function useLogin() {
30505
30576
  password: "default",
30506
30577
  accessToken: infoUser.accessToken
30507
30578
  };
30508
- setIsLoginGoogle(false);
30579
+ dispatch(setIsLoginGoogle(false));
30509
30580
  return Promise.resolve(userLogin(dataLogin)).then(function () {
30510
30581
  history.push(HOMEPAGE_STUDENT);
30511
30582
  });
@@ -30513,7 +30584,7 @@ var useLogin = function useLogin() {
30513
30584
  }
30514
30585
  }();
30515
30586
 
30516
- if (_temp31 && _temp31.then) return _temp31.then(function () {});
30587
+ if (_temp35 && _temp35.then) return _temp35.then(function () {});
30517
30588
  });
30518
30589
  }, function (err) {
30519
30590
  var _err$response7, _err$response7$data;
@@ -30524,7 +30595,7 @@ var useLogin = function useLogin() {
30524
30595
  }));
30525
30596
  });
30526
30597
 
30527
- return Promise.resolve(_temp35 && _temp35.then ? _temp35.then(_temp34) : _temp34(_temp35));
30598
+ return Promise.resolve(_temp39 && _temp39.then ? _temp39.then(_temp38) : _temp38(_temp39));
30528
30599
  } catch (e) {
30529
30600
  return Promise.reject(e);
30530
30601
  }
@@ -30532,7 +30603,7 @@ var useLogin = function useLogin() {
30532
30603
 
30533
30604
  var getInformationSetting = function getInformationSetting() {
30534
30605
  try {
30535
- var _temp37 = _catch(function () {
30606
+ var _temp41 = _catch(function () {
30536
30607
  return Promise.resolve(getSchoolSettings()).then(function (res) {
30537
30608
  dispatch(setSandboxMode(res.data.isSandboxMode));
30538
30609
  });
@@ -30540,14 +30611,89 @@ var useLogin = function useLogin() {
30540
30611
  console.error(err);
30541
30612
  });
30542
30613
 
30543
- return Promise.resolve(_temp37 && _temp37.then ? _temp37.then(function () {}) : void 0);
30614
+ return Promise.resolve(_temp41 && _temp41.then ? _temp41.then(function () {}) : void 0);
30544
30615
  } catch (e) {
30545
30616
  return Promise.reject(e);
30546
30617
  }
30547
30618
  };
30548
30619
 
30620
+ var fnLoginSSO = function fnLoginSSO(clickHandler) {
30621
+ try {
30622
+ msalInstance.handleRedirectPromise().then(function (tokenResponse) {
30623
+ try {
30624
+ var _temp44 = function () {
30625
+ if (!tokenResponse) {
30626
+ var accounts = msalInstance.getAllAccounts();
30627
+
30628
+ var _temp45 = function () {
30629
+ if (accounts.length === 0) {
30630
+ msalInstance.loginRedirect();
30631
+ } else {
30632
+ var currentAccount = accounts[0];
30633
+ return Promise.resolve(getCurrentAccount(currentAccount, clickHandler)).then(function () {});
30634
+ }
30635
+ }();
30636
+
30637
+ if (_temp45 && _temp45.then) return _temp45.then(function () {});
30638
+ } else {
30639
+ var currentAccount = tokenResponse.account;
30640
+ return Promise.resolve(getCurrentAccount(currentAccount, clickHandler)).then(function () {});
30641
+ }
30642
+ }();
30643
+
30644
+ return Promise.resolve(_temp44 && _temp44.then ? _temp44.then(function () {}) : void 0);
30645
+ } catch (e) {
30646
+ return Promise.reject(e);
30647
+ }
30648
+ })["catch"](function (err) {
30649
+ console.error(err);
30650
+ });
30651
+ return Promise.resolve();
30652
+ } catch (e) {
30653
+ return Promise.reject(e);
30654
+ }
30655
+ };
30656
+
30657
+ var getCurrentAccount = function getCurrentAccount(account, clickHandler) {
30658
+ try {
30659
+ var fullName = account.name;
30660
+ var infoLogin = {
30661
+ firstName: fullName.split(' ').slice(0, -1).join(' '),
30662
+ lastName: fullName.split(' ').slice(-1).join(' '),
30663
+ fullName: fullName,
30664
+ imageUrl: "",
30665
+ email: account.username,
30666
+ accessToken: account.idTokenClaims.aio,
30667
+ googleId: account.tenantId
30668
+ };
30669
+ dispatch(setInforUserGoogle(infoLogin));
30670
+ return Promise.resolve(fnIsCheckLogin(TypeLogin.MicrosoftSSO, infoLogin, account.idTokenClaims.aio, clickHandler)).then(function () {});
30671
+ } catch (e) {
30672
+ return Promise.reject(e);
30673
+ }
30674
+ };
30675
+
30676
+ var initInformationSSO = function initInformationSSO() {
30677
+ try {
30678
+ var _msalInstance = new msalBrowser.PublicClientApplication(msalConfig);
30679
+
30680
+ setMsalInstance(_msalInstance);
30681
+ return Promise.resolve();
30682
+ } catch (e) {
30683
+ return Promise.reject(e);
30684
+ }
30685
+ };
30686
+
30687
+ React.useEffect(function () {
30688
+ var redirectUrl = window.location.href;
30689
+
30690
+ if (!!msalInstance && redirectUrl.includes("code") && redirectUrl.includes("client_info")) {
30691
+ fnLoginSSO();
30692
+ }
30693
+ }, [JSON.stringify(msalInstance)]);
30549
30694
  React.useEffect(function () {
30550
30695
  getInformationSetting();
30696
+ initInformationSSO();
30551
30697
  }, []);
30552
30698
  return {
30553
30699
  defaultInfo: defaultInfo,
@@ -30559,14 +30705,13 @@ var useLogin = function useLogin() {
30559
30705
  fnIsCheckLogin: fnIsCheckLogin,
30560
30706
  isLoginGoogle: isLoginGoogle,
30561
30707
  infoUser: infoUser,
30562
- setInfoUser: setInfoUser,
30563
30708
  submitLogin: submitLogin,
30564
- setIsLoginGoogle: setIsLoginGoogle,
30565
30709
  googleClientId: googleClientId,
30566
30710
  googleRecaptchaId: googleRecaptchaId,
30567
30711
  handleCancelModelAssign: handleCancelModelAssign,
30568
30712
  openModelAssign: openModelAssign,
30569
- handleAssignTeacherByCode: handleAssignTeacherByCode
30713
+ handleAssignTeacherByCode: handleAssignTeacherByCode,
30714
+ fnLoginSSO: fnLoginSSO
30570
30715
  };
30571
30716
  };
30572
30717
 
@@ -30594,8 +30739,7 @@ var BlockSelectTeacher = function BlockSelectTeacher(_ref) {
30594
30739
  openModal = _ref.openModal,
30595
30740
  onSubmit = _ref.onSubmit,
30596
30741
  token = _ref.token,
30597
- email = _ref.email,
30598
- setOpenModal = _ref.setOpenModal;
30742
+ email = _ref.email;
30599
30743
 
30600
30744
  var _useState = React.useState(false),
30601
30745
  modal = _useState[0],
@@ -30604,12 +30748,6 @@ var BlockSelectTeacher = function BlockSelectTeacher(_ref) {
30604
30748
  React.useEffect(function () {
30605
30749
  setModal(openModal);
30606
30750
  }, [openModal]);
30607
-
30608
- var toggle = function toggle() {
30609
- setModal(!modal);
30610
- setOpenModal(!modal);
30611
- };
30612
-
30613
30751
  var dispatch = reactRedux.useDispatch();
30614
30752
 
30615
30753
  var _useState2 = React.useState([]),
@@ -30629,6 +30767,12 @@ var BlockSelectTeacher = function BlockSelectTeacher(_ref) {
30629
30767
  setLoading = _useState5[1];
30630
30768
 
30631
30769
  var timeout = React.useRef();
30770
+
30771
+ var toggle = function toggle() {
30772
+ setModal(!modal);
30773
+ dispatch(setIsLoginGoogle(!modal));
30774
+ };
30775
+
30632
30776
  var loadData = React.useCallback(function () {
30633
30777
  try {
30634
30778
  var _temp3 = function _temp3() {
@@ -30786,16 +30930,17 @@ var BlockLogin = function BlockLogin(_ref) {
30786
30930
  setIsShowPassword = _useLogin.setIsShowPassword,
30787
30931
  fnIsCheckLogin = _useLogin.fnIsCheckLogin,
30788
30932
  isLoginGoogle = _useLogin.isLoginGoogle,
30789
- setInfoUser = _useLogin.setInfoUser,
30790
30933
  submitLogin = _useLogin.submitLogin,
30791
30934
  infoUser = _useLogin.infoUser,
30792
- setIsLoginGoogle = _useLogin.setIsLoginGoogle,
30793
- googleClientId = _useLogin.googleClientId;
30935
+ googleClientId = _useLogin.googleClientId,
30936
+ fnLoginSSO = _useLogin.fnLoginSSO;
30794
30937
 
30795
30938
  var togglePasswordVisible = function togglePasswordVisible() {
30796
30939
  return setIsShowPassword(!isShowPassword);
30797
30940
  };
30798
30941
 
30942
+ var dispatch = reactRedux.useDispatch();
30943
+
30799
30944
  var _useGoogleReCaptcha = reactGoogleRecaptchaV3.useGoogleReCaptcha(),
30800
30945
  executeRecaptcha = _useGoogleReCaptcha.executeRecaptcha;
30801
30946
 
@@ -30823,12 +30968,7 @@ var BlockLogin = function BlockLogin(_ref) {
30823
30968
  name = _res$profileObj.name;
30824
30969
  var accessToken = res.accessToken;
30825
30970
  var googleId = res.googleId;
30826
-
30827
- if (email.includes("@gmail")) {
30828
- alert("Please login with your school email");
30829
- return;
30830
- }
30831
-
30971
+ console.log("assss");
30832
30972
  var infoLogin = {
30833
30973
  firstName: givenName,
30834
30974
  lastName: familyName,
@@ -30838,8 +30978,8 @@ var BlockLogin = function BlockLogin(_ref) {
30838
30978
  accessToken: accessToken,
30839
30979
  googleId: googleId
30840
30980
  };
30841
- setInfoUser(infoLogin);
30842
- fnIsCheckLogin(infoLogin, accessToken, clickHandler);
30981
+ dispatch(setInforUserGoogle(infoLogin));
30982
+ fnIsCheckLogin(TypeLogin.Google, infoLogin, accessToken, clickHandler);
30843
30983
  }
30844
30984
  };
30845
30985
 
@@ -30923,6 +31063,15 @@ var BlockLogin = function BlockLogin(_ref) {
30923
31063
  cookiePolicy: 'single_host_origin',
30924
31064
  className: "" + styles["btn-login-google"]
30925
31065
  })), React__default.createElement("div", {
31066
+ className: styles["btn-login-sso"] + " mb-3"
31067
+ }, React__default.createElement("div", {
31068
+ className: styles["btn-login-with-sso"],
31069
+ onClick: function onClick() {
31070
+ return fnLoginSSO(clickHandler);
31071
+ }
31072
+ }, React__default.createElement("img", {
31073
+ src: "images/Single-Sign-On.png"
31074
+ }), " Login with SSO")), React__default.createElement("div", {
30926
31075
  className: "d-flex justify-content-between"
30927
31076
  }, React__default.createElement(reactRouterDom.Link, {
30928
31077
  to: "/forgot-password",
@@ -30945,8 +31094,7 @@ var BlockLogin = function BlockLogin(_ref) {
30945
31094
  },
30946
31095
  openModal: isLoginGoogle,
30947
31096
  token: infoUser.accessToken,
30948
- email: infoUser.email,
30949
- setOpenModal: setIsLoginGoogle
31097
+ email: infoUser.email
30950
31098
  }), React__default.createElement(BlockAssignTeacherByCode, {
30951
31099
  open: openModelAssign,
30952
31100
  onClose: onCancelModelAssign,
@@ -40193,6 +40341,8 @@ var initialState = {
40193
40341
  isConversationOneToOne: false,
40194
40342
  isSandboxMode: false,
40195
40343
  language: "en",
40344
+ isLoginGoogle: false,
40345
+ inforUserGoogle: null,
40196
40346
  amplitude: {
40197
40347
  user_id: "",
40198
40348
  status: "",
@@ -40217,6 +40367,10 @@ var commonReducer = toolkit.createReducer(initialState, function (builder) {
40217
40367
  state.user = action.payload;
40218
40368
  }).addCase(setSidebar, function (state, action) {
40219
40369
  state.sidebarShow = action.payload;
40370
+ }).addCase(setIsLoginGoogle, function (state, action) {
40371
+ state.isLoginGoogle = action.payload;
40372
+ }).addCase(setInforUserGoogle, function (state, action) {
40373
+ state.inforUserGoogle = action.payload;
40220
40374
  }).addCase(setAlert, function (state, action) {
40221
40375
  state.alert = action.payload;
40222
40376
  }).addCase(reset, function (_state, _action) {