527 lines
19 KiB
JavaScript
527 lines
19 KiB
JavaScript
"use strict";
|
|
(() => {
|
|
var exports = {};
|
|
exports.id = 3459;
|
|
exports.ids = [3459];
|
|
exports.modules = {
|
|
|
|
/***/ 9168:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
// ESM COMPAT FLAG
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
"default": () => (/* binding */ Login),
|
|
"getServerSideProps": () => (/* binding */ getServerSideProps)
|
|
});
|
|
|
|
// EXTERNAL MODULE: external "react/jsx-runtime"
|
|
var jsx_runtime_ = __webpack_require__(997);
|
|
// EXTERNAL MODULE: external "react"
|
|
var external_react_ = __webpack_require__(6689);
|
|
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
// EXTERNAL MODULE: external "next/head"
|
|
var head_ = __webpack_require__(968);
|
|
var head_default = /*#__PURE__*/__webpack_require__.n(head_);
|
|
// EXTERNAL MODULE: ./functions/frontend/clearCaches.js
|
|
var clearCaches = __webpack_require__(9137);
|
|
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
|
|
var fetchApi = __webpack_require__(6729);
|
|
;// CONCATENATED MODULE: ./functions/frontend/userLogin.js
|
|
// @ts-check
|
|
|
|
|
|
/**
|
|
* user login form submit function
|
|
* ==============================================================================
|
|
* @param {object} params
|
|
* @param {any} params.e
|
|
* @param {React.Dispatch<React.SetStateAction<string | boolean>>} params.setAlert
|
|
* @param {React.Dispatch<React.SetStateAction<boolean>>} params.setLoading
|
|
* @param {any} params.query
|
|
*/ async function userLogin({ e , setAlert , setLoading , query }) {
|
|
/** Initialize
|
|
* ==============================================================================
|
|
*/ e.preventDefault();
|
|
setLoading(true);
|
|
let email = e.target["email-or-username-input"];
|
|
let password = e.target["password"];
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/** Sanitize
|
|
* ==============================================================================
|
|
*/ if (email?.value === "" && password?.value === "") {
|
|
email.classList.add("warning");
|
|
password.classList.add("warning");
|
|
setAlert("No Email or Password Provided");
|
|
setLoading(false);
|
|
return;
|
|
} else if (password?.value === "") {
|
|
setAlert(false);
|
|
password.classList.add("warning");
|
|
setAlert(true);
|
|
setLoading(false);
|
|
return;
|
|
} else {
|
|
email.classList.remove("warning");
|
|
password.classList.remove("warning");
|
|
setAlert(false);
|
|
}
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
let postBodyObject = {
|
|
email: email.value,
|
|
password: password.value,
|
|
query: query
|
|
};
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
(0,fetchApi/* default */.Z)("/api/loginUser", {
|
|
method: "post",
|
|
body: postBodyObject
|
|
}).then(async (res)=>{
|
|
console.log(res);
|
|
if (res.user && res.user.auth) {
|
|
localStorage.setItem("userid", res.user.userid);
|
|
localStorage.setItem("csrf", res.user.csrf_k);
|
|
localStorage.setItem("user", JSON.stringify(res.userPayload));
|
|
(0,clearCaches/* default */.Z)().then(()=>{
|
|
window.location.reload();
|
|
});
|
|
} else {
|
|
setAlert(res.msg);
|
|
setLoading(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
|
|
var LoadingBlock = __webpack_require__(5264);
|
|
// EXTERNAL MODULE: ./components/pages/login/SocialLogin.jsx + 3 modules
|
|
var SocialLogin = __webpack_require__(8374);
|
|
;// CONCATENATED MODULE: ./components/pages/login/LoginForm.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** @type {import("@/package-shared/types").LoginFormContextType} */ // @ts-ignore
|
|
const init = {};
|
|
const LoginFormContext = /*#__PURE__*/ external_react_default().createContext(init);
|
|
/**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - React component props including { children }
|
|
* @param {import("@/package-shared/types").UserType | null} [props.user]
|
|
* @param {any} props.query
|
|
*/ function LoginForm({ user , query }) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ /** @type {[ alert: string | boolean, setAlert: React.Dispatch<React.SetStateAction<string | boolean>> ]} */ // @ts-ignore
|
|
let { 0: alert , 1: setAlert } = (0,external_react_.useState)(null);
|
|
let { 0: loading , 1: setLoading } = (0,external_react_.useState)(false);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(LoginFormContext.Provider, {
|
|
value: {
|
|
loading,
|
|
setLoading,
|
|
alert,
|
|
setAlert,
|
|
user
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx(SocialLogin/* default */.Z, {
|
|
user: user,
|
|
userType: "admin",
|
|
setLoading: setLoading
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "w-full justify-center relative",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
className: "bg-white dark:bg-slate-800 px-3 relative z-10",
|
|
children: "OR"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("hr", {
|
|
className: "absolute"
|
|
})
|
|
]
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "w-full flex-col items-stretch gap-4",
|
|
children: [
|
|
loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {}),
|
|
alert && /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
className: "p-2 justify-center text-sm border border-solid border-orange-400 rounded bg-orange-50",
|
|
children: alert
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("form", {
|
|
className: "flex flex-col gap-2 w-full",
|
|
onSubmit: (/** @type {any} */ e)=>{
|
|
userLogin({
|
|
e,
|
|
setAlert,
|
|
setLoading,
|
|
query: query
|
|
});
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("input", {
|
|
type: "text",
|
|
name: "email-or-username-input",
|
|
id: "email-or-username-input",
|
|
placeholder: "Email or username",
|
|
defaultValue: query?.email ? query.email : "",
|
|
required: true,
|
|
onInput: (e)=>{
|
|
if (alert) setAlert(false);
|
|
}
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("input", {
|
|
type: "password",
|
|
name: "password",
|
|
id: "password-input",
|
|
placeholder: "Password",
|
|
required: true,
|
|
onInput: (e)=>{
|
|
if (alert) setAlert(false);
|
|
}
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("button", {
|
|
type: "submit",
|
|
children: "Login"
|
|
})
|
|
]
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
className: "flex flex-col items-center w-full mb-2",
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx("a", {
|
|
href: "/send-password-reset-link",
|
|
className: "text-secondary font-semibold",
|
|
children: "Forgot Password?"
|
|
})
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "flex items-center gap-2 justify-center w-full mb-2 flex-wrap",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
children: "Dont have an account yet?"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("a", {
|
|
href: "/create-account",
|
|
className: "text-secondary font-semibold",
|
|
children: "Register Now"
|
|
})
|
|
]
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "justify-center text-sm text-secondary",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("a", {
|
|
href: "/terms",
|
|
className: "text-secondary",
|
|
children: "Terms and Conditions"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("a", {
|
|
href: "/privacy",
|
|
className: "text-secondary",
|
|
children: "Privacy Policy"
|
|
})
|
|
]
|
|
})
|
|
]
|
|
})
|
|
]
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
|
|
// EXTERNAL MODULE: ./functions/backend/userAuth.js
|
|
var userAuth = __webpack_require__(370);
|
|
var userAuth_default = /*#__PURE__*/__webpack_require__.n(userAuth);
|
|
// EXTERNAL MODULE: ./components/general/Logo.jsx
|
|
var Logo = __webpack_require__(4017);
|
|
// EXTERNAL MODULE: ./components/general/LoadingScreen.jsx
|
|
var LoadingScreen = __webpack_require__(6478);
|
|
;// CONCATENATED MODULE: ./pages/login.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* 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(props) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ const user = {};
|
|
external_react_default().useEffect(()=>{
|
|
setTimeout(()=>{
|
|
if (props.query.invite && props.user) {
|
|
window.location.pathname = "/create-account";
|
|
}
|
|
}, 1000);
|
|
if (!props.query.invite) {
|
|
localStorage.setItem("user", "{}");
|
|
}
|
|
}, []);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
if (props.query.invite && props.user) {
|
|
return /*#__PURE__*/ jsx_runtime_.jsx(LoadingScreen/* default */.Z, {});
|
|
}
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
|
|
children: [
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)((head_default()), {
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("title", {
|
|
children: "Login to your account"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("meta", {
|
|
name: "description",
|
|
content: "Login to your account"
|
|
})
|
|
]
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("main", {
|
|
className: "w-screen h-screen flex items-center justify-center p-4 md:p-8",
|
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "card col items-center no-hover max-w-md w-full bg-white p-4 sm:p-6 overflow-auto minimal-scrollbars",
|
|
style: {
|
|
maxHeight: "calc(100vh - 40px)"
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx(Logo/* default */.Z, {}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("hr", {}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("h3", {
|
|
className: "m-0 text-lg font-semibold",
|
|
children: "Login to your account"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx(LoginForm, {
|
|
user: props.user,
|
|
query: props.query
|
|
})
|
|
]
|
|
})
|
|
})
|
|
]
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** @type {import("next").GetServerSideProps} */ async function getServerSideProps({ req , res , query }) {
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* User Authentication
|
|
*
|
|
* @description User authentication
|
|
*/ const user = await userAuth_default()(req, res);
|
|
if (user) {
|
|
return {
|
|
redirect: {
|
|
destination: `/admin`,
|
|
permanent: false
|
|
}
|
|
};
|
|
}
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Page/Site Data Data Fetching
|
|
*
|
|
* @description Fetch data on the server before returning
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Server props return
|
|
*
|
|
* @description Return data fetched on the server side
|
|
*/ return {
|
|
props: {
|
|
user: user,
|
|
query
|
|
}
|
|
};
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6843:
|
|
/***/ ((module) => {
|
|
|
|
module.exports = require("@mui/icons-material/ContentCopy");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5557:
|
|
/***/ ((module) => {
|
|
|
|
module.exports = require("@mui/icons-material/MenuBookTwoTone");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9174:
|
|
/***/ ((module) => {
|
|
|
|
module.exports = require("@mui/material/Snackbar");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 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");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1017:
|
|
/***/ ((module) => {
|
|
|
|
module.exports = require("path");
|
|
|
|
/***/ })
|
|
|
|
};
|
|
;
|
|
|
|
// 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, [4017,5264,6729,4480,370,8374,6478], () => (__webpack_exec__(9168)));
|
|
module.exports = __webpack_exports__;
|
|
|
|
})(); |