touchstudy-core 0.1.4 → 0.1.6
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/index.js +64 -103
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +58 -97
- package/dist/index.modern.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/isLocalHost.d.ts +2 -0
- package/dist/utils/useGoogleSignOut.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -5,7 +5,6 @@ var toolkit = require('@reduxjs/toolkit');
|
|
5
5
|
var moment = _interopDefault(require('moment'));
|
6
6
|
var React = require('react');
|
7
7
|
var React__default = _interopDefault(React);
|
8
|
-
var reactGoogleRecaptchaV3 = require('react-google-recaptcha-v3');
|
9
8
|
var reactstrap = require('reactstrap');
|
10
9
|
var formik = require('formik');
|
11
10
|
var yup = require('yup');
|
@@ -24,11 +23,14 @@ var setUser = toolkit.createAction("common/setUser");
|
|
24
23
|
var setLanguage = toolkit.createAction("common/setLanguage");
|
25
24
|
var reset = toolkit.createAction("common/reset");
|
26
25
|
|
26
|
+
var isLocalHost = Boolean(window.location.hostname === "localhost" || window.location.hostname === "[::1]" || window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));
|
27
|
+
|
27
28
|
var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
|
28
|
-
var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
|
29
29
|
var ACCESS_TOKEN = "ACCESS_TOKEN";
|
30
30
|
var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
|
31
|
-
var BASE_URL =
|
31
|
+
var BASE_URL = function () {
|
32
|
+
return isLocalHost ? "https://localhost:7045" : "https://api.studypeak.io";
|
33
|
+
}();
|
32
34
|
var PUSHER_CONFIG = {
|
33
35
|
cluster: "ap1",
|
34
36
|
key: "9018c77328885a14150b"
|
@@ -190,88 +192,64 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
190
192
|
onNavigate = _ref.onNavigate,
|
191
193
|
isTeacher = _ref.isTeacher;
|
192
194
|
var dispatch = reactRedux.useDispatch();
|
193
|
-
var
|
194
|
-
|
195
|
-
|
195
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
196
|
+
onNavigate: onNavigate
|
197
|
+
}),
|
196
198
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
197
|
-
var clickHandler = React.useCallback(function () {
|
198
|
-
try {
|
199
|
-
var _exit = false;
|
200
|
-
if (!executeRecaptcha) {
|
201
|
-
return Promise.resolve();
|
202
|
-
}
|
203
|
-
return Promise.resolve(_catch(function () {
|
204
|
-
return Promise.resolve(executeRecaptcha("login")).then(function (result) {
|
205
|
-
_exit = true;
|
206
|
-
return result;
|
207
|
-
});
|
208
|
-
}, function (error) {
|
209
|
-
console.log({
|
210
|
-
error: error
|
211
|
-
});
|
212
|
-
}));
|
213
|
-
} catch (e) {
|
214
|
-
return Promise.reject(e);
|
215
|
-
}
|
216
|
-
}, [executeRecaptcha]);
|
217
|
-
var handleVerify = React.useCallback(function () {}, []);
|
218
199
|
var onSuccessGoogle = function onSuccessGoogle(res) {
|
219
200
|
try {
|
220
|
-
|
201
|
+
var _temp3 = function () {
|
221
202
|
if (!!(res !== null && res !== void 0 && res.accessToken)) {
|
203
|
+
var _temp2 = function _temp2() {
|
204
|
+
dispatch(setLoading(false));
|
205
|
+
};
|
222
206
|
var _res$profileObj = res.profileObj,
|
223
207
|
email = _res$profileObj.email,
|
224
208
|
imageUrl = _res$profileObj.imageUrl,
|
225
209
|
name = _res$profileObj.name;
|
226
210
|
var accessToken = res.tokenObj.id_token;
|
227
211
|
var googleId = res.googleId;
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
var isFirstLogin = res1.data.isFirstLogin;
|
246
|
-
var tokenJWT = res1.data.token;
|
247
|
-
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
248
|
-
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
249
|
-
if (!isTeacher && isFirstLogin) {
|
250
|
-
onNavigate("/register/info");
|
251
|
-
} else {
|
252
|
-
onNavigate("/");
|
253
|
-
}
|
254
|
-
});
|
255
|
-
}, function (error) {
|
256
|
-
var _error$response, _error$response$data;
|
257
|
-
var message = undefined;
|
258
|
-
var type = error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.type;
|
259
|
-
if (type === AuthenticationMessage.NotAllowedToRegister) {
|
260
|
-
alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
|
261
|
-
} else if (type) {
|
262
|
-
var _error$response2, _error$response2$data;
|
263
|
-
message = (error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.message) || ERROR_MESSAGE;
|
212
|
+
var infoLogin = {
|
213
|
+
imageUrl: imageUrl,
|
214
|
+
fullName: name,
|
215
|
+
email: email,
|
216
|
+
token: accessToken,
|
217
|
+
googleId: googleId
|
218
|
+
};
|
219
|
+
var role = isTeacher ? "Teacher" : "Student";
|
220
|
+
dispatch(setLoading(true));
|
221
|
+
var _temp = _catch(function () {
|
222
|
+
return Promise.resolve(apiLoginGoogle(infoLogin, role)).then(function (res1) {
|
223
|
+
var isFirstLogin = res1.data.isFirstLogin;
|
224
|
+
var tokenJWT = res1.data.token;
|
225
|
+
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
226
|
+
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
227
|
+
if (!isTeacher && isFirstLogin) {
|
228
|
+
onNavigate("/register/info");
|
264
229
|
} else {
|
265
|
-
|
266
|
-
message = (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE;
|
230
|
+
onNavigate("/");
|
267
231
|
}
|
268
|
-
message && alert(message);
|
269
|
-
handleSignOut();
|
270
232
|
});
|
271
|
-
|
233
|
+
}, function (error) {
|
234
|
+
var _error$response, _error$response$data;
|
235
|
+
var message = undefined;
|
236
|
+
var type = error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.type;
|
237
|
+
if (type === AuthenticationMessage.NotAllowedToRegister) {
|
238
|
+
alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
|
239
|
+
} else if (type) {
|
240
|
+
var _error$response2, _error$response2$data;
|
241
|
+
message = (error === null || error === void 0 ? void 0 : (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.message) || ERROR_MESSAGE;
|
242
|
+
} else {
|
243
|
+
var _error$response3;
|
244
|
+
message = (error === null || error === void 0 ? void 0 : (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || ERROR_MESSAGE;
|
245
|
+
}
|
246
|
+
message && alert(message);
|
247
|
+
handleSignOut();
|
272
248
|
});
|
249
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
273
250
|
}
|
274
|
-
}()
|
251
|
+
}();
|
252
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
275
253
|
} catch (e) {
|
276
254
|
return Promise.reject(e);
|
277
255
|
}
|
@@ -283,16 +261,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
283
261
|
return React__default.createElement(formik.Formik, {
|
284
262
|
initialValues: defaultInfo,
|
285
263
|
validationSchema: schema,
|
286
|
-
onSubmit: function (
|
287
|
-
try {
|
288
|
-
return Promise.resolve(clickHandler()).then(function (clickHandlerRes) {
|
289
|
-
if (!clickHandlerRes) return;
|
290
|
-
values.captcha = clickHandlerRes;
|
291
|
-
});
|
292
|
-
} catch (e) {
|
293
|
-
return Promise.reject(e);
|
294
|
-
}
|
295
|
-
}
|
264
|
+
onSubmit: function onSubmit() {}
|
296
265
|
}, function (formikProps) {
|
297
266
|
var handleSubmit = formikProps.handleSubmit;
|
298
267
|
return React__default.createElement(reactstrap.Row, {
|
@@ -307,10 +276,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
307
276
|
}, React__default.createElement("img", {
|
308
277
|
src: "/images/logo.jpeg",
|
309
278
|
className: "" + styles["img-login-rectangle"]
|
310
|
-
}), React__default.createElement(reactstrap.
|
311
|
-
action: "login",
|
312
|
-
onVerify: handleVerify
|
313
|
-
})), React__default.createElement(reactstrap.Col, {
|
279
|
+
}), React__default.createElement(reactstrap.Col, {
|
314
280
|
className: "p-0 mt-1 mb-4"
|
315
281
|
}, React__default.createElement(GoogleLogin__default, {
|
316
282
|
clientId: GOOGLE_CLIENT_ID,
|
@@ -389,19 +355,11 @@ var Login = function Login(_ref) {
|
|
389
355
|
md: 12,
|
390
356
|
xs: 12,
|
391
357
|
className: "d-flex justify-content-center h-100 align-items-center"
|
392
|
-
}, React__default.createElement(reactGoogleRecaptchaV3.GoogleReCaptchaProvider, {
|
393
|
-
useRecaptchaNet: true,
|
394
|
-
reCaptchaKey: GOOGLE_RECAPTCHA_ID,
|
395
|
-
scriptProps: {
|
396
|
-
async: true,
|
397
|
-
defer: true,
|
398
|
-
appendTo: "body"
|
399
|
-
}
|
400
358
|
}, React__default.createElement(BlockLogin, {
|
401
359
|
defaultInfo: defaultInfo,
|
402
360
|
onNavigate: onNavigate,
|
403
361
|
isTeacher: isTeacher
|
404
|
-
}))))
|
362
|
+
}))));
|
405
363
|
};
|
406
364
|
|
407
365
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
@@ -745,8 +703,11 @@ var getInfo = function getInfo() {
|
|
745
703
|
|
746
704
|
var LayoutContext = function LayoutContext(_ref) {
|
747
705
|
var children = _ref.children,
|
748
|
-
role = _ref.role
|
749
|
-
|
706
|
+
role = _ref.role,
|
707
|
+
onNavigate = _ref.onNavigate;
|
708
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
709
|
+
onNavigate: onNavigate
|
710
|
+
}),
|
750
711
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
751
712
|
var dispatch = reactRedux.useDispatch();
|
752
713
|
var user = reactRedux.useSelector(function (state) {
|
@@ -1381,16 +1342,16 @@ var canAccess = function canAccess(userRoles, componentRoles) {
|
|
1381
1342
|
var historyCore = history.createBrowserHistory();
|
1382
1343
|
|
1383
1344
|
Object.defineProperty(exports, 'I18nextProvider', {
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1345
|
+
enumerable: true,
|
1346
|
+
get: function () {
|
1347
|
+
return reactI18next.I18nextProvider;
|
1348
|
+
}
|
1388
1349
|
});
|
1389
1350
|
Object.defineProperty(exports, 'useTranslation', {
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1351
|
+
enumerable: true,
|
1352
|
+
get: function () {
|
1353
|
+
return reactI18next.useTranslation;
|
1354
|
+
}
|
1394
1355
|
});
|
1395
1356
|
exports.ACCESS_TOKEN = ACCESS_TOKEN;
|
1396
1357
|
exports.BASE_URL = BASE_URL;
|