"use strict"; (() => { var exports = {}; exports.id = 765; exports.ids = [765]; exports.modules = { /***/ 9137: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (/* binding */ clearCaches) /* harmony export */ }); // @ts-check /** * Clear Caches function * ============================================================================== */ async function clearCaches() { try { /** Initialize * ============================================================================== */ /** ********************* Variables */ const keys = await caches.keys(); if (keys[0]) { await Promise.all(keys.map((key)=>{ return caches.delete(key); })); } } catch (/** @type {any} */ error) { console.log("Error in clearing cache =>", error.message); } } /***/ }), /***/ 1780: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ Login), /* harmony export */ "getServerSideProps": () => (/* binding */ getServerSideProps) /* harmony export */ }); /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997); /* 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__(6689); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var next_head__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(968); /* harmony import */ var next_head__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(next_head__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7147); /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6729); /* harmony import */ var _functions_frontend_clearCaches__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9137); /* harmony import */ var _components_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5264); /** * Imports * ============================================================================== */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// const userAuth = __webpack_require__(370); /** * Main Component { Functional } * ============================================================================== * @param {Object} props - React component props including { children } * @param {import("@/package-shared/types").UserType} props.user * @param {any} props.query */ function Login({ user , query }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// // ## Head Items let head = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), { children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("title", { children: "Loging Out | Datasquirel" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", { name: "description", content: "Login you out" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("script", { src: "https://accounts.google.com/gsi/client" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("script", { src: "https://connect.facebook.net/en_US/sdk.js", crossOrigin: "anonymous" }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{ localStorage.setItem("user", "{}"); localStorage.removeItem("csrf"); // window.location.pathname = "/" }, []); react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{ function redirect() { if (query?.invite && query?.login) { return window.location.href = `/login` + window.location.search; // return window.location.href = `/login?email=${query.email}`; } if (query?.login) { return window.location.href = `/login`; } if (localStorage.getItem("logoutParadigm")?.match(/reset/)) { return window.location.href = "/login"; } if (user?.social_platform?.match(/google/)) { localStorage.setItem("google_prompt_skipped", "logout"); } window.location.pathname = "/"; } //////////////////////////////////////// (0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)("/api/logoutUser").then(async (res)=>{ await (0,_functions_frontend_clearCaches__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z)(); let regs = await navigator.serviceWorker.getRegistrations(); for(let i = 0; i < regs.length; i++){ const reg = regs[i]; await reg.unregister(); } try { FB.init({ appId: "", cookie: true, xfbml: true, version: "v13.0" }); FB.getLoginStatus((response)=>{ if (response.authResponse) { FB.logout((res)=>{ redirect(); }); } else { google.accounts.id.initialize({ client_id: "" }); if (user?.social_platform?.match(/google/) && user.social_id) { google.accounts.id.revoke(); google.accounts.id.revoke(user.social_id, (done)=>{ console.log(done.error); redirect(); }); } else { redirect(); } } }); } catch (error) { (0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)("/api/admin/clientError", { method: "post", body: { component: "logout-page-component/lines-111-142", message: error.message, user: user } }); } }); }, []); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), { children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((next_head__WEBPACK_IMPORTED_MODULE_2___default()), { children: head }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("main", { className: "w-screen h-screen flex items-center justify-center p-4 md:p-8", children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "card max-w-md flex-col items-center bg-white p-6 rounded border border-slate-200 border-solid", children: [ /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("a", { href: "/", className: "flex items-center gap-2", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("img", { src: "/images/logo-icon-alt-2.png", alt: "Logo Icon", width: 37 }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", { className: "font-bold text-2xl", children: "Datasquirel" }) ] }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h3", { className: "text-lg m-0 mt-4 text-slate-400", children: "Logging out" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, { position: "relative", width: "20px" }) ] }) }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** * Server Side Props or Static Props * ============================================================================== * @type {import("next").GetServerSideProps} */ async function getServerSideProps({ req , res , query }) { // ## Environment processes //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * User Authentication * * @description User authentication */ const user = await userAuth(req, res); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// if (user) { console.log(user.csrf_k); try { const allowedAuthKeysPath = process.env.DSQL_USER_LOGIN_KEYS_PATH; const allowedAuthKeyPath = `${allowedAuthKeysPath}/${user.csrf_k}`; console.log("allowedAuthKeyPath", allowedAuthKeyPath); fs__WEBPACK_IMPORTED_MODULE_3___default().unlinkSync(allowedAuthKeyPath); } catch (/** @type {any} */ error) { console.log(`Logout API error: ${error.message}`); } } /** * Page/Site Data Data Fetching * * @description Fetch data on the server before returning */ res.setHeader("Set-Cookie", [ "datasquirelAuthKey=none;max-age=0", "usertype=none;max-age=0", `refresh_properties=1;Max-Age=7000`, ]); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Server props return * * @description Return data fetched on the server side */ return { props: { user: user, logged_out: true, query } }; //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /***/ }), /***/ 968: /***/ ((module) => { module.exports = require("next/head"); /***/ }), /***/ 6689: /***/ ((module) => { module.exports = require("react"); /***/ }), /***/ 997: /***/ ((module) => { module.exports = require("react/jsx-runtime"); /***/ }), /***/ 2261: /***/ ((module) => { module.exports = require("serverless-mysql"); /***/ }), /***/ 4300: /***/ ((module) => { module.exports = require("buffer"); /***/ }), /***/ 6113: /***/ ((module) => { module.exports = require("crypto"); /***/ }), /***/ 7147: /***/ ((module) => { module.exports = require("fs"); /***/ }), /***/ 3685: /***/ ((module) => { module.exports = require("http"); /***/ }) }; ; // load runtime var __webpack_require__ = require("../webpack-runtime.js"); __webpack_require__.C(exports); var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId)) var __webpack_exports__ = __webpack_require__.X(0, [5264,6729,4480,370], () => (__webpack_exec__(1780))); module.exports = __webpack_exports__; })();