dsql-admin/dsql-app/.local_dist/server/pages/reset-password.js

16 lines
11 KiB
JavaScript
Raw Normal View History

2024-12-15 11:27:16 +00:00
"use strict";(()=>{var e={};e.id=7537,e.ids=[3220,7537],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},75370:(e,t,r)=>{r.r(t),r.d(t,{config:()=>L,default:()=>b,getServerSideProps:()=>O,getStaticPaths:()=>R,getStaticProps:()=>N,reportWebVitals:()=>I,routeModule:()=>k,unstable_getServerProps:()=>T,unstable_getServerSideProps:()=>C,unstable_getStaticParams:()=>q,unstable_getStaticPaths:()=>$,unstable_getStaticProps:()=>M});var s={};r.r(s),r.d(s,{ResetPasswordContext:()=>j,default:()=>D,getServerSideProps:()=>A});var n=r(63865),a=r(9455),o=r(30671),i=r(49407),l=r(89600),c=r(8732),u=r(82015),p=r.n(u),d=r(71457),m=r(87472),g=r(32415),f=r(20048),S=r.n(f),h=r(63715),_=r(13002),x=r(77463),P=r.n(x),y=r(22373),v=r.n(y),w=r(27825),E=r.n(w);let j=p().createContext({});function D(e){let{email:t}=e,r="Reset Password | Datasquirel",s="Set a new password",n=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("title",{children:r}),(0,c.jsx)("meta",{name:"description",content:s}),(0,c.jsx)(m.A,{pageTitle:r,pageDescription:s,pagePathname:"/"})]}),[a,o]=p().useState(!1),[i,l]=p().useState(!1);return(0,c.jsx)(d.A,{head:n,user:e.user,children:(0,c.jsx)(j.Provider,{value:{user:e.user},children:(0,c.jsx)("main",{children:(0,c.jsxs)("section",{children:[a&&(0,c.jsx)(g.A,{}),(0,c.jsx)("div",{className:"main-container flex-col items-start",children:i?(0,c.jsx)(_.A,{message:"Password Updated Sucessfully. Redirecting you ..."}):(0,c.jsxs)(p().Fragment,{children:[(0,c.jsx)("h1",{className:"m-0 text-4xl",children:"Reset Password"}),(0,c.jsx)("span",{children:"Please enter new passord and confirm it"}),(0,c.jsxs)("form",{className:"max-w-xl w-full flex flex-col items-stretch gap-4",onSubmit:e=>{o(!0),e.preventDefault();let r=e.target,s=r.password.value,n=r["confirm-password"].classList.contains("warning");if(s?.length<8){window.alert("Password must be at least 8 characters"),setTimeout(()=>{o(!1)},500);return}if(n){window.alert("Passwords don't match"),setTimeout(()=>{o(!1)},500);return}(0,h.A)(`/api/resetPassword?email=${t}&password=${s}`).then(e=>{setTimeout(()=>{o(!1)},500),setTimeout(()=>{window.location.href="/logout?login=true"},1e3),e.success&&l(!0)})},children:[(0,c.jsx)("input",{type:"password",name:"password",id:"password",className:"w-full",placeholder:"New Password",required:!0}),(0,c.jsx)("input",{type:"password",name:"confirm-password",id:"confirm-password",className:"w-full",placeholder:"Confirm New Password",required:!0,onInput:e=>{let t=e.target,r=t.closest("form");try{r.password.value.match(RegExp(`^${E().escapeRegExp(t.value)}$`))?t.classList.remove("warning"):t.classList.add("warning")}catch(t){(0,h.A)("/api/admin/clientError",{method:"post",body:{component:"reset-password-page-component/lines-170-177",message:t.message,user:{}}}),e.target.classList.add("warning")}}}),(0,c.jsx)("button",{children:"Reset Password"})]})]})})]})})})})}async function A({req:e,res:t,query:r}){let s=await S()(e,t);if(!r?.token?.toString()?.match(/./))return{redirect:{destination:"/",permanent:!1}};let n=null;try{let e=P()({encryptedString:r.token.toString()}),t=JSON.parse(e||"");if(Date.now()-t.dateCode>36e5)return{redirect:{destination:"/",permanent:!1}};n=t.email}catch(e){return v()({component:"reset-password-page-component/getServersideProps/lines-251-260",message:e.message,user:s}),{redirect:{destination:"/",permanent:!1}}}return n?.match(/./)?{props:{user:s,email:n}}:{redirect:{destination:"/",permanent:!1}}}let b=(0,o.M)(s,"default"),N=(0,o.M)(s,"getStaticProps"),R=(0,o.M)(s,"getStaticPaths"),O=(0,o.M)(s,"getServerSideProps"),L=(0,o.M)(s,"config"),I=(0,o.M)(s,"reportWebVitals"),M=(0,o.M)(s,"unstable_getStaticProps"),$=(0,o.M)(s,"unstable_getStaticPaths"),q=(0,o.M)(s,"unstable_getStaticParams"),T=(0,o.M)(s,"unstable_getServerProps"),C=(0,o.M)(s,"unstable_getServerSideProps"),k=new n.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/reset-password",pathname:"/reset-password",bu
2024-12-08 19:56:57 +00:00
Error Message: ${t}
2024-12-09 09:39:09 +00:00
Component: ${r}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=`
2024-12-08 19:56:57 +00:00
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
2024-12-09 09:39:09 +00:00
User Email: ${e?.email}`),a?.url&&(n+=`
URL: ${a.url}`),a?.body&&(n+=`
Request Body: ${JSON.stringify(a.body,null,4)}`),i&&(n+=`
IP: ${i}`),n+=`
Date: ${o.toDateString()}
========================================`,s.existsSync("./.tmp/error.log")||s.writeFileSync("./.tmp/error.log","","utf-8");let l=s.readFileSync("./.tmp/error.log","utf-8");s.writeFileSync("./.tmp/error.log",n),s.appendFileSync("./.tmp/error.log",`
2024-12-08 19:56:57 +00:00
2024-12-09 09:39:09 +00:00
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},77463:(e,t,r)=>{let{scryptSync:s,createDecipheriv:n}=r(55511),{Buffer:a}=r(79428);e.exports=({encryptedString:e,encryptionKey:t,encryptionSalt:r})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let o=t||process.env.DSQL_ENCRYPTION_PASSWORD,i=r||process.env.DSQL_ENCRYPTION_SALT,l=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!o?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let c=n("aes-192-cbc",s(o,i,l),a.alloc(16,0));try{let t=c.update(e,"hex","utf8");return t+=c.final("utf8")}catch(t){return console.log("Error in decrypting =>",t.message),e}}},67216:(e,t,r)=>{let s=r(9973),n=r(31976),a=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:n()}});async function o(...e){try{let t=await a.query(...e);return await a.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=o},31976:(e,t,r)=>{let s=r(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let t=`${e}/ca-cert.pem`;if(!s.existsSync(t)){console.log(`${t} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},49407:(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(8732);r(82015);var n=r(20883);function a(e){return(0,s.jsxs)(n.Html,{lang:"en",children:[(0,s.jsxs)(n.Head,{children:[(0,s.jsx)("meta",{name:"author",content:"Datasquirel"}),(0,s.jsx)("meta",{name:"Copyright",content:`Copyright (c) ${new Date().getFullYear()} Datasquirel`}),"dev_dev".match(/dev/)&&(0,s.jsx)("meta",{name:"robots",content:"noindex,nofollow"}),(0,s.jsx)("link",{rel:"preconnect",href:"https://fonts.googleapis.com/",crossOrigin:"anonymous"}),(0,s.jsx)("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Poppins"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Inter"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=IBM+Plex+Mono"}),(0,s.jsx)("script",{src:"/scripts/themeSelector.js"}),(0,s.jsx)("meta",{httpEquiv:"Content-Type",content:"text/html; charset=UTF-8"}),(0,s.jsx)("meta",{property:"og:site_name",content:"DATASQUIREL"}),(0,s.jsx)("meta",{property:"og:type",content:"website"}),(0,s.jsx)("meta",{name:"twitter:card",content:"summary"}),(0,s.jsx)("meta",{property:"og:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("meta",{itemProp:"image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("meta",{name:"twitter:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("link",{rel:"stylesheet",href:"/styles/prism.css"}),(0,s.jsx)("script",{src:"/scripts/prism.js",async:!0}),(0,s.jsx)("script",{dangerouslySetInnerHTML:{__html:"var DSQL = {}"}})]}),(0,s.jsxs)("body",{children:[(0,s.jsx)(n.Main,{}),(0,s.jsx)(n.NextScript,{})]})]})}},9455:(e,t)=>{var r;Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(r||(r={}))},27825:e=>{e.exports=require("lodash")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},8732:e=>{e.exports=require("react/jsx-runtime")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=requ