touchstudy-core 0.1.5 → 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 +52 -95
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +54 -97
- package/dist/index.modern.js.map +1 -1
- 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');
|
@@ -27,11 +26,10 @@ var reset = toolkit.createAction("common/reset");
|
|
27
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}$/));
|
28
27
|
|
29
28
|
var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.googleusercontent.com";
|
30
|
-
var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
|
31
29
|
var ACCESS_TOKEN = "ACCESS_TOKEN";
|
32
30
|
var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
|
33
31
|
var BASE_URL = function () {
|
34
|
-
return isLocalHost ? "https://localhost:7045" : "api.studypeak.io";
|
32
|
+
return isLocalHost ? "https://localhost:7045" : "https://api.studypeak.io";
|
35
33
|
}();
|
36
34
|
var PUSHER_CONFIG = {
|
37
35
|
cluster: "ap1",
|
@@ -194,88 +192,64 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
194
192
|
onNavigate = _ref.onNavigate,
|
195
193
|
isTeacher = _ref.isTeacher;
|
196
194
|
var dispatch = reactRedux.useDispatch();
|
197
|
-
var
|
198
|
-
|
199
|
-
|
195
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
196
|
+
onNavigate: onNavigate
|
197
|
+
}),
|
200
198
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
201
|
-
var clickHandler = React.useCallback(function () {
|
202
|
-
try {
|
203
|
-
var _exit = false;
|
204
|
-
if (!executeRecaptcha) {
|
205
|
-
return Promise.resolve();
|
206
|
-
}
|
207
|
-
return Promise.resolve(_catch(function () {
|
208
|
-
return Promise.resolve(executeRecaptcha("login")).then(function (result) {
|
209
|
-
_exit = true;
|
210
|
-
return result;
|
211
|
-
});
|
212
|
-
}, function (error) {
|
213
|
-
console.log({
|
214
|
-
error: error
|
215
|
-
});
|
216
|
-
}));
|
217
|
-
} catch (e) {
|
218
|
-
return Promise.reject(e);
|
219
|
-
}
|
220
|
-
}, [executeRecaptcha]);
|
221
|
-
var handleVerify = React.useCallback(function () {}, []);
|
222
199
|
var onSuccessGoogle = function onSuccessGoogle(res) {
|
223
200
|
try {
|
224
|
-
|
201
|
+
var _temp3 = function () {
|
225
202
|
if (!!(res !== null && res !== void 0 && res.accessToken)) {
|
203
|
+
var _temp2 = function _temp2() {
|
204
|
+
dispatch(setLoading(false));
|
205
|
+
};
|
226
206
|
var _res$profileObj = res.profileObj,
|
227
207
|
email = _res$profileObj.email,
|
228
208
|
imageUrl = _res$profileObj.imageUrl,
|
229
209
|
name = _res$profileObj.name;
|
230
210
|
var accessToken = res.tokenObj.id_token;
|
231
211
|
var googleId = res.googleId;
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
var isFirstLogin = res1.data.isFirstLogin;
|
250
|
-
var tokenJWT = res1.data.token;
|
251
|
-
localStorage.setItem("USER_INFORMATION", JSON.stringify(infoLogin));
|
252
|
-
localStorage.setItem(ACCESS_TOKEN, tokenJWT);
|
253
|
-
if (!isTeacher && isFirstLogin) {
|
254
|
-
onNavigate("/register/info");
|
255
|
-
} else {
|
256
|
-
onNavigate("/");
|
257
|
-
}
|
258
|
-
});
|
259
|
-
}, function (error) {
|
260
|
-
var _error$response, _error$response$data;
|
261
|
-
var message = undefined;
|
262
|
-
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;
|
263
|
-
if (type === AuthenticationMessage.NotAllowedToRegister) {
|
264
|
-
alert("가입 권한이 없는 계정입니다. 관리자에게 문의하세요.");
|
265
|
-
} else if (type) {
|
266
|
-
var _error$response2, _error$response2$data;
|
267
|
-
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");
|
268
229
|
} else {
|
269
|
-
|
270
|
-
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("/");
|
271
231
|
}
|
272
|
-
message && alert(message);
|
273
|
-
handleSignOut();
|
274
232
|
});
|
275
|
-
|
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();
|
276
248
|
});
|
249
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
277
250
|
}
|
278
|
-
}()
|
251
|
+
}();
|
252
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(function () {}) : void 0);
|
279
253
|
} catch (e) {
|
280
254
|
return Promise.reject(e);
|
281
255
|
}
|
@@ -287,16 +261,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
287
261
|
return React__default.createElement(formik.Formik, {
|
288
262
|
initialValues: defaultInfo,
|
289
263
|
validationSchema: schema,
|
290
|
-
onSubmit: function (
|
291
|
-
try {
|
292
|
-
return Promise.resolve(clickHandler()).then(function (clickHandlerRes) {
|
293
|
-
if (!clickHandlerRes) return;
|
294
|
-
values.captcha = clickHandlerRes;
|
295
|
-
});
|
296
|
-
} catch (e) {
|
297
|
-
return Promise.reject(e);
|
298
|
-
}
|
299
|
-
}
|
264
|
+
onSubmit: function onSubmit() {}
|
300
265
|
}, function (formikProps) {
|
301
266
|
var handleSubmit = formikProps.handleSubmit;
|
302
267
|
return React__default.createElement(reactstrap.Row, {
|
@@ -311,10 +276,7 @@ var BlockLogin = function BlockLogin(_ref) {
|
|
311
276
|
}, React__default.createElement("img", {
|
312
277
|
src: "/images/logo.jpeg",
|
313
278
|
className: "" + styles["img-login-rectangle"]
|
314
|
-
}), React__default.createElement(reactstrap.
|
315
|
-
action: "login",
|
316
|
-
onVerify: handleVerify
|
317
|
-
})), React__default.createElement(reactstrap.Col, {
|
279
|
+
}), React__default.createElement(reactstrap.Col, {
|
318
280
|
className: "p-0 mt-1 mb-4"
|
319
281
|
}, React__default.createElement(GoogleLogin__default, {
|
320
282
|
clientId: GOOGLE_CLIENT_ID,
|
@@ -393,19 +355,11 @@ var Login = function Login(_ref) {
|
|
393
355
|
md: 12,
|
394
356
|
xs: 12,
|
395
357
|
className: "d-flex justify-content-center h-100 align-items-center"
|
396
|
-
}, React__default.createElement(reactGoogleRecaptchaV3.GoogleReCaptchaProvider, {
|
397
|
-
useRecaptchaNet: true,
|
398
|
-
reCaptchaKey: GOOGLE_RECAPTCHA_ID,
|
399
|
-
scriptProps: {
|
400
|
-
async: true,
|
401
|
-
defer: true,
|
402
|
-
appendTo: "body"
|
403
|
-
}
|
404
358
|
}, React__default.createElement(BlockLogin, {
|
405
359
|
defaultInfo: defaultInfo,
|
406
360
|
onNavigate: onNavigate,
|
407
361
|
isTeacher: isTeacher
|
408
|
-
}))))
|
362
|
+
}))));
|
409
363
|
};
|
410
364
|
|
411
365
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
@@ -749,8 +703,11 @@ var getInfo = function getInfo() {
|
|
749
703
|
|
750
704
|
var LayoutContext = function LayoutContext(_ref) {
|
751
705
|
var children = _ref.children,
|
752
|
-
role = _ref.role
|
753
|
-
|
706
|
+
role = _ref.role,
|
707
|
+
onNavigate = _ref.onNavigate;
|
708
|
+
var _useGoogleSignOut = useGoogleSignOut({
|
709
|
+
onNavigate: onNavigate
|
710
|
+
}),
|
754
711
|
handleSignOut = _useGoogleSignOut.handleSignOut;
|
755
712
|
var dispatch = reactRedux.useDispatch();
|
756
713
|
var user = reactRedux.useSelector(function (state) {
|