123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- "use strict";
- exports.id = 1223;
- exports.ids = [1223];
- exports.modules = {
- /***/ 966:
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
- /* harmony export */ });
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
- /* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(71853);
- /* harmony import */ var next_router__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(next_router__WEBPACK_IMPORTED_MODULE_2__);
- /* harmony import */ var _utils_navigation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(57933);
- var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_utils_navigation__WEBPACK_IMPORTED_MODULE_3__]);
- _utils_navigation__WEBPACK_IMPORTED_MODULE_3__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
- const RedirectToLoginPage = ()=>{
- const router = (0,next_router__WEBPACK_IMPORTED_MODULE_2__.useRouter)();
- (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{
- const { asPath } = router;
- router.replace((0,_utils_navigation__WEBPACK_IMPORTED_MODULE_3__/* .getLoginNavigationUrl */ .gk)(asPath));
- }, [
- router
- ]);
- return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {});
- };
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (RedirectToLoginPage);
- __webpack_async_result__();
- } catch(e) { __webpack_async_result__(e); } });
- /***/ }),
- /***/ 1223:
- /***/ ((module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
- /* harmony export */ });
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
- /* harmony import */ var _RedirectToLoginPage__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(966);
- /* harmony import */ var _utils_auth_login__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(22197);
- var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_RedirectToLoginPage__WEBPACK_IMPORTED_MODULE_2__, _utils_auth_login__WEBPACK_IMPORTED_MODULE_3__]);
- ([_RedirectToLoginPage__WEBPACK_IMPORTED_MODULE_2__, _utils_auth_login__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
- /**
- * withAuth is a Higher-Order Component (HOC) that wraps a component and checks if the user is authenticated.
- * If the user is authenticated, it renders the wrapped component.
- * If the user is not authenticated, it redirects the user to the login page.
- *
- * @param {React.ComponentType} WrappedComponent - The component to wrap and protect with authentication check.
- *
- * @returns {React.ComponentType} If the user is authenticated, returns the WrappedComponent.
- * If not, returns RedirectToLoginPage component.
- *
- * @example
- * const ProtectedComponent = withAuth(MyComponent);
- */ const withAuth = (WrappedComponent)=>{
- const WithAuth = (props)=>{
- const { 0: isReady , 1: setIsReady } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
- /**
- * we need to wait for the initial render to check if the user is authenticated
- * because when it's server-side rendered, the user is not authenticated yet
- */ (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{
- setIsReady(true);
- }, []);
- if (!isReady) {
- return null; // or return a loading spinner
- }
- return (0,_utils_auth_login__WEBPACK_IMPORTED_MODULE_3__/* .isLoggedIn */ .jl)() ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(WrappedComponent, {
- ...props
- }) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_RedirectToLoginPage__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {});
- };
- return WithAuth;
- };
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (withAuth);
- __webpack_async_result__();
- } catch(e) { __webpack_async_result__(e); } });
- /***/ })
- };
- ;
- //# sourceMappingURL=1223.js.map
|