"use strict"; (() => { var exports = {}; exports.id = 7570; exports.ids = [7570]; exports.modules = { /***/ 4211: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (/* binding */ Dashboard), /* 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 _functions_backend_suAdminUserAuth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1503); /* harmony import */ var _functions_backend_suAdminUserAuth__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_suAdminUserAuth__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6729); /* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(370); /* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_4__); // @ts-check /** * ============================================================================== * Imports * ============================================================================== */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Main Component { Functional } * ============================================================================== * @param {Object} props - Server props * @param {null} props.user */ function Dashboard({ user }) { /** * Get Contexts * * @abstract { React.useContext } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Javascript Variables * * @abstract Non hook variables and functions */ const pageTitle = "Super User Login | Datasquirel"; const pageDescription = "Welcome to your data app"; let head = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, { children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("title", { children: pageTitle }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", { name: "description", content: pageDescription }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * React Hooks * * @abstract { useState, useEffect, useRef, etc ... } */ //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Function Return * * @abstract Main Function Return */ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("section", { className: "w-full h-screen justify-center items-center", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((next_head__WEBPACK_IMPORTED_MODULE_2___default()), { children: head }), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "p-6 bg-slate-100 rounded w-full max-w-2xl flex flex-col items-center", children: [ true && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(SuInfo, {}), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form", { onSubmit: (e)=>{ e.preventDefault(); /** @type {HTMLFormElement} */ // @ts-ignore const formEl = e.target; (0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z)("/api/admin/loginSuUser", { method: "post", body: { email: formEl["email"].value, password: formEl["password"].value, authKey: formEl["auth-key"].value } }).then((res)=>{ window.location.reload(); }); }, className: "flex flex-col items-stretch gap-4 w-full", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", { type: "text", name: "email", id: "email", placeholder: "Email Address" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", { type: "password", name: "password", id: "password", placeholder: "Password" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", { type: "password", name: "auth-key", id: "auth-key", placeholder: "Auth Key" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("button", { children: "Login" }) ] }) ] }) ] }); //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** * ============================================================================== * Server Side Props or Static Props * ============================================================================== * @type {import("next").GetServerSideProps} */ async function getServerSideProps({ req , res , query }) { /** * User Auth * * @description User Auth */ const user = await _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_4___default()(req, res, true); if (user?.id == 1 && "true") { console.log("Admin User Detected ..."); } const suAdminUser = await _functions_backend_suAdminUserAuth__WEBPACK_IMPORTED_MODULE_3___default()(req); if (suAdminUser?.logged_in_status) { return { redirect: { destination: `/su`, permanent: false } }; } //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// /** * Server props return * * @description Return data fetched on the server side */ return { props: { user: suAdminUser } }; //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// } function SuInfo() { return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", { className: "flex flex-col items-center gap-2 text-center", children: [ /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h1", { className: "text-2xl text-center m-0", children: "Super User Login" }), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", { children: [ "This area is reserved only for the owner of this Admin. To login use the info in your ", /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", { children: "dsql.env" }), " File. Use the env variables as follows. Your ", /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("i", { children: "email address" }), " is the same address used to register the first user account" ] }), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("ul", { className: "p-0", children: [ /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("li", { children: [ "Password:", " ", /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("i", { className: "info small w-auto inline", children: "dsql.env::" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", { children: " DSQL_USER_KEY" }) ] }), /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("li", { children: [ "Auth Key:", " ", /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("i", { className: "info small w-auto inline", children: "dsql.env::" }), /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", { children: " DSQL_SPECIAL_KEY" }) ] }) ] }) ] }); } /***/ }), /***/ 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, [6729,4480,370,1503], () => (__webpack_exec__(4211))); module.exports = __webpack_exports__; })();