1 line
5.1 KiB
JavaScript
1 line
5.1 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3459],{10545:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/login",function(){return t(79168)}])},26478:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});var r=t(85893),n=(t(67294),t(95264));function a(){return(0,r.jsx)("div",{className:"flex flex-col gap-4 items-center justify-center w-full h-screen p-6 bg-slate-100",children:(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 px-6 py-20 bg-white rounded shadow-sm max-w-2xl w-full",children:[(0,r.jsx)("img",{src:"/images/logo-icon-alt-2.webp",alt:"Datasquirel Logo",width:60}),(0,r.jsx)("div",{className:"w-10 h-10 flex flex-col items-center justify-center",children:(0,r.jsx)(n.Z,{width:"25px",position:"relative"})})]})})}},79168:function(e,s,t){"use strict";t.r(s),t.d(s,{__N_SSP:function(){return w},default:function(){return j}});var r=t(85893),n=t(67294),a=t(9008),i=t.n(a),l=t(47568),o=t(97582),c=t(29137),u=t(86729);function d(){return d=(0,l.Z)((function(e){var s,t,r,n,a,i,d;return(0,o.__generator)(this,(function(m){return s=e.e,t=e.setAlert,r=e.setLoading,n=e.query,s.preventDefault(),r(!0),a=s.target["email-or-username-input"],i=s.target.password,""===(null===a||void 0===a?void 0:a.value)&&""===(null===i||void 0===i?void 0:i.value)?(a.classList.add("warning"),i.classList.add("warning"),t("No Email or Password Provided"),r(!1),[2]):""===(null===i||void 0===i?void 0:i.value)?(t(!1),i.classList.add("warning"),t(!0),r(!1),[2]):(a.classList.remove("warning"),i.classList.remove("warning"),t(!1),d={email:a.value,password:i.value,query:n},(0,u.Z)("/api/loginUser",{method:"post",body:d}).then(function(){var e=(0,l.Z)((function(e){return(0,o.__generator)(this,(function(s){return console.log(e),e.user&&e.user.auth?(localStorage.setItem("userid",e.user.userid),localStorage.setItem("csrf",e.user.csrf_k),localStorage.setItem("user",JSON.stringify(e.userPayload)),(0,c.Z)().then((function(){window.location.reload()}))):(t(e.msg),r(!1)),[2]}))}));return function(s){return e.apply(this,arguments)}}()),[2])}))})),d.apply(this,arguments)}var m=t(95264),f=t(98374),x={},h=n.createContext(x);function p(e){var s=e.user,t=e.query,a=(0,n.useState)(null),i=a[0],l=a[1],o=(0,n.useState)(!1),c=o[0],u=o[1];return(0,r.jsxs)(h.Provider,{value:{loading:c,setLoading:u,alert:i,setAlert:l,user:s},children:[(0,r.jsx)(f.Z,{user:s,userType:"admin",setLoading:u}),(0,r.jsxs)("div",{className:"w-full justify-center relative",children:[(0,r.jsx)("span",{className:"bg-white dark:bg-slate-800 px-3 relative z-10",children:"OR"}),(0,r.jsx)("hr",{className:"absolute"})]}),(0,r.jsxs)("div",{className:"w-full flex-col items-stretch gap-4",children:[c&&(0,r.jsx)(m.Z,{}),i&&(0,r.jsx)("div",{className:"p-2 justify-center text-sm border border-solid border-orange-400 rounded bg-orange-50",children:i}),(0,r.jsxs)("form",{className:"flex flex-col gap-2 w-full",onSubmit:function(e){!function(e){d.apply(this,arguments)}({e:e,setAlert:l,setLoading:u,query:t})},children:[(0,r.jsx)("input",{type:"text",name:"email-or-username-input",id:"email-or-username-input",placeholder:"Email or username",defaultValue:(null===t||void 0===t?void 0:t.email)?t.email:"",required:!0,onInput:function(e){i&&l(!1)}}),(0,r.jsx)("input",{type:"password",name:"password",id:"password-input",placeholder:"Password",required:!0,onInput:function(e){i&&l(!1)}}),(0,r.jsx)("button",{type:"submit",children:"Login"})]}),(0,r.jsx)("div",{className:"flex flex-col items-center w-full mb-2",children:(0,r.jsx)("a",{href:"/send-password-reset-link",className:"text-secondary font-semibold",children:"Forgot Password?"})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 justify-center w-full mb-2 flex-wrap",children:[(0,r.jsx)("span",{children:"Dont have an account yet?"}),(0,r.jsx)("a",{href:"/create-account",className:"text-secondary font-semibold",children:"Register Now"})]}),(0,r.jsxs)("div",{className:"justify-center text-sm text-secondary",children:[(0,r.jsx)("a",{href:"/terms",className:"text-secondary",children:"Terms and Conditions"}),(0,r.jsx)("a",{href:"/privacy",className:"text-secondary",children:"Privacy Policy"})]})]})]})}var v=t(64017),g=t(26478),w=!0;function j(e){return n.useEffect((function(){setTimeout((function(){e.query.invite&&e.user&&(window.location.pathname="/create-account")}),1e3),e.query.invite||localStorage.setItem("user","{}")}),[]),e.query.invite&&e.user?(0,r.jsx)(g.Z,{}):(0,r.jsxs)(n.Fragment,{children:[(0,r.jsxs)(i(),{children:[(0,r.jsx)("title",{children:"Login to your account"}),(0,r.jsx)("meta",{name:"description",content:"Login to your account"})]}),(0,r.jsx)("main",{className:"w-screen h-screen flex items-center justify-center p-4 md:p-8",children:(0,r.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:[(0,r.jsx)(v.Z,{}),(0,r.jsx)("hr",{}),(0,r.jsx)("h3",{className:"m-0 text-lg font-semibold",children:"Login to your account"}),(0,r.jsx)(p,{user:e.user,query:e.query})]})})]})}}},function(e){e.O(0,[8374,9774,2888,179],(function(){return s=10545,e(e.s=s);var s}));var s=e.O();_N_E=s}]); |