dsql-admin/dsql-app/.local_dist/server/pages/email-verification.js

16 lines
11 KiB
JavaScript
Raw Normal View History

2024-12-05 07:03:33 +00:00
"use strict";(()=>{var e={};e.id=6712,e.ids=[636,6712],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}}})},71956:(e,t,r)=>{r.r(t),r.d(t,{config:()=>k,default:()=>E,getServerSideProps:()=>D,getStaticPaths:()=>A,getStaticProps:()=>b,reportWebVitals:()=>w,routeModule:()=>$,unstable_getServerProps:()=>L,unstable_getServerSideProps:()=>O,unstable_getStaticParams:()=>N,unstable_getStaticPaths:()=>M,unstable_getStaticProps:()=>R});var s={};r.r(s),r.d(s,{default:()=>_,getServerSideProps:()=>q});var i=r(63865),n=r(9455),a=r(30671),o=r(49407),l=r(68268),u=r(8732),c=r(82015),m=r.n(c);r(27912);var p=r(20048),d=r.n(p),x=r(32415),f=r(63715),g=r(83007),h=r.n(g),S=r(71457),y=r(68942),P=r.n(y),j=r(67216),v=r.n(j);function _({user:e,verified:t}){let[r,s]=m().useState(!1),[i,n]=m().useState(null);return t?(0,u.jsx)(S.A,{head:(0,u.jsxs)(m().Fragment,{children:[(0,u.jsx)("title",{children:"Verify Email Address"}),(0,u.jsx)("meta",{name:"description",content:"Verify your email address"})]}),user:e,children:(0,u.jsx)("main",{className:"flex items-center justify-center w-full p-8",children:(0,u.jsx)("div",{className:"login-block gap-2",children:(0,u.jsxs)("div",{className:"flex items-center gap-4",children:[(0,u.jsx)("img",{src:"/images/checkmark.svg",alt:"check-mark",width:30}),(0,u.jsx)("span",{className:"text-xl",children:"Email Verification Successfull!"})]})})})}):(0,u.jsx)(m().Fragment,{children:(0,u.jsx)(S.A,{head:(0,u.jsxs)(m().Fragment,{children:[(0,u.jsx)("title",{children:"Verify Email Address"}),(0,u.jsx)("meta",{name:"description",content:"Verify your email address"})]}),user:e,children:(0,u.jsx)("main",{className:"flex flex-col items-center p-8 justify-center w-full",children:(0,u.jsxs)("div",{className:"login-block gap-2 flex-col max-w-lg",children:[i&&(0,u.jsx)("div",{className:i.class+" w-full rounded py-2 px-4 flex justify-center",children:i.msg}),r&&(0,u.jsx)(x.A,{position:"absolute"}),(0,u.jsx)("h1",{className:"text-2xl m-0 ",children:"Verify Email Address"}),(0,u.jsx)("span",{children:"Please click the button below to send verification link"}),(0,u.jsx)("button",{className:"w-full",onClick:function(e){e.preventDefault(),s(!0),(0,f.A)("/api/sendEmailVerificationLink").then(e=>{s(!1),e.success&&n({msg:"Email Sent. Please check mailbox",class:"bg-emerald-100"})})},children:(0,u.jsx)("span",{children:"Send Verification Link"})}),(0,u.jsx)("button",{className:"w-full outlined",onClick:e=>{window.history.back()},children:(0,u.jsx)("span",{children:"Go Back"})})]})})})})}async function q({req:e,res:t,query:r}){let s;let i=!1;try{s=await d()(e,t);let n=r?.token;if(n){let e=h()(n.toString());if(e)try{s=JSON.parse(e)}catch(e){P()({component:"email-verification/index-page-component/getServerSideProps/line-255",message:e.message,user:{}}),s=null,n=null}}if(!s)return{redirect:{destination:"/logout",permanent:!1}};if(s.verification_status?.toString().match(/^[1-5]$/))return{redirect:{destination:"/admin",permanent:!1}};let a=await v()(`SELECT id FROM users WHERE verification_status > 0 AND id='${s.id}'`);if(a&&a[0])return{redirect:{destination:"/admin",permanent:!1}};if(s?.dateCode){let e=s.dateCode;Date.now()-parseInt(e)>18e5?(s=null,n=null):(await v()(`UPDATE users SET verification_status='1' WHERE id='${s.id}'`),i=!0)}}catch(e){return P()({component:"email-verification/index-page-component/getServerSideProps/main-catch-error",message:e.message,user:{}}),{redirect:{destination:"/logout",permanent:!1}}}return{props:{user:s,verified:i}}}let E=(0,a.M)(s,"default"),b=(0,a.M)(s,"getStaticProps"),A=(0,a.M)(s,"getStaticPaths"),D=(0,a.M)(s,"getServerSideProps"),k=(0,a.M)(s,"config"),w=(0,a.M)(s,"reportWebVitals"),R=(0,a.M)(s,"unstable_getStaticProps"),M=(0,a.M)(s,"unstable_getStaticPaths"),N=(0,a.M)(s,"unstable_getStaticParams"),L=(0,a.M)(s,"unstable_getServerProps"),O=(0,a.M)(s,"unstable_getServerSideProps"),$=new i.PagesRouteModule({definition:{kind:n.A.PAGES,page:
Error Message: ${t}
Component: ${r}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(i+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),n?.url&&(i+=`
URL: ${n.url}`),n?.body&&(i+=`
Request Body: ${JSON.stringify(n.body,null,4)}`),o&&(i+=`
IP: ${o}`),i+=`
Date: ${a.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",i),s.appendFileSync("./.tmp/error.log",`
2024-11-05 11:12:42 +00:00
2024-12-05 07:03:33 +00:00
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},20048:(e,t,r)=>{r(81630);let s=r(67216),i=r(83007),n=r(29021);async function a(e,t,r,a){if(!e.cookies?.datasquirelAuthKey?.match(/./))return null;let o=i(e.cookies.datasquirelAuthKey);if(!o)return null;let l=JSON.parse(o);if(!l.csrf_k||r&&!e.headers["x-csrf-auth"]?.match(RegExp(`${l.csrf_k}`)))return null;let u=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!u)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(r&&!n.existsSync(`${u}/${l.csrf_k}`))return null;if(0==l.verification_status&&!r){let e=await s(`SELECT verification_status FROM users WHERE id='${l.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}return l?.date&&Date.now()-l.date>6048e5?null:l}e.exports=a},83007:(e,t,r)=>{let{scryptSync:s,createDecipheriv:i}=r(55511),{Buffer:n}=r(79428);e.exports=e=>{let t=i("aes-192-cbc",s(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),n.alloc(16,0));try{let r=t.update(e,"hex","utf8");return r+=t.final("utf8")}catch(e){return null}}},67216:(e,t,r)=>{let s=r(9973),i=r(31976),n=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:i()}});async function a(...e){try{let t=await n.query(...e);return await n.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=a},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:()=>n});var s=r(8732);r(82015);var i=r(20883);function n(e){return(0,s.jsxs)(i.Html,{lang:"en",children:[(0,s.jsxs)(i.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)(i.Main,{}),(0,s.jsx)(i.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={}))},66099:e=>{e.exports=require("@mui/system")},37616:e=>{e.exports=require("@mui/system/DefaultPropsProvider")},24509:e=>{e.exports=require("@mui/system/InitColorScheme