1 line
8.9 KiB
JavaScript
1 line
8.9 KiB
JavaScript
"use strict";(()=>{var e={};e.id=9634,e.ids=[3220,9634],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,s){return s in t?t[s]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,s)):"function"==typeof t&&"default"===s?t:void 0}}})},38954:(e,t,s)=>{s.r(t),s.d(t,{config:()=>E,default:()=>S,getServerSideProps:()=>j,getStaticPaths:()=>v,getStaticProps:()=>y,reportWebVitals:()=>P,routeModule:()=>O,unstable_getServerProps:()=>D,unstable_getServerSideProps:()=>I,unstable_getStaticParams:()=>b,unstable_getStaticPaths:()=>N,unstable_getStaticProps:()=>A});var r={};s.r(r),s.d(r,{default:()=>_,getServerSideProps:()=>g});var n=s(63865),a=s(9455),o=s(30671),i=s(5583),l=s(19796),c=s(8732);s(82015);var u=s(27912),d=s.n(u),p=s(61197),m=s(46169),h=s(92702),f=s(89923);function _(){let e=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("title",{children:"Super User Login | Datasquirel"}),(0,c.jsx)("meta",{name:"description",content:"Welcome to your data app"})]});return(0,c.jsxs)("section",{className:"w-full h-screen justify-center items-center",children:[(0,c.jsx)(d(),{children:e}),(0,c.jsxs)("div",{className:"p-6 bg-slate-100 rounded w-full max-w-2xl flex flex-col items-center",children:[(0,c.jsx)(x,{}),(0,c.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=e.target;(0,m.A)("/api/admin/loginSuUser",{method:"post",body:{email:t.email.value,password:t.password.value,authKey:t["auth-key"].value}}).then(e=>{window.location.reload()})},className:"flex flex-col items-stretch gap-4 w-full",children:[(0,c.jsx)("input",{type:"text",name:"email",id:"email",placeholder:"Email Address"}),(0,c.jsx)("input",{type:"password",name:"password",id:"password",placeholder:"Password"}),(0,c.jsx)("input",{type:"password",name:"auth-key",id:"auth-key",placeholder:"Auth Key"}),(0,c.jsx)("button",{children:"Login"})]})]})]})}async function g({req:e,res:t,query:s}){let r=await (0,h.A)(e,t,!0);(0,f.A)(r)&&console.log("Admin User Detected ...");let n=await (0,p.A)(e);return n?.logged_in_status?{redirect:{destination:"/su",permanent:!1}}:{props:{user:n}}}function x(){return(0,c.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center",children:[(0,c.jsx)("h1",{className:"text-2xl text-center m-0",children:"Super User Login"}),(0,c.jsxs)("span",{children:["This area is reserved only for the owner of this Admin. To login use the info in your ",(0,c.jsx)("b",{children:"dsql.env"})," File. Use the env variables as follows. Your ",(0,c.jsx)("i",{children:"email address"})," is the same address used to register the first user account"]}),(0,c.jsxs)("ul",{className:"p-0",children:[(0,c.jsxs)("li",{children:["Password:"," ",(0,c.jsx)("i",{className:"info small w-auto inline",children:"dsql.env::"}),(0,c.jsx)("b",{children:" DSQL_USER_KEY"})]}),(0,c.jsxs)("li",{children:["Auth Key:"," ",(0,c.jsx)("i",{className:"info small w-auto inline",children:"dsql.env::"}),(0,c.jsx)("b",{children:" DSQL_SPECIAL_KEY"})]})]})]})}let S=(0,o.M)(r,"default"),y=(0,o.M)(r,"getStaticProps"),v=(0,o.M)(r,"getStaticPaths"),j=(0,o.M)(r,"getServerSideProps"),E=(0,o.M)(r,"config"),P=(0,o.M)(r,"reportWebVitals"),A=(0,o.M)(r,"unstable_getStaticProps"),N=(0,o.M)(r,"unstable_getStaticPaths"),b=(0,o.M)(r,"unstable_getStaticParams"),D=(0,o.M)(r,"unstable_getServerProps"),I=(0,o.M)(r,"unstable_getServerSideProps"),O=new n.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/su/login",pathname:"/su/login",bundlePath:"",filename:""},components:{App:l.default,Document:i.default},userland:r})},61197:(e,t,s)=>{s.d(t,{A:()=>a});var r=s(71205),n=s(41939);async function a(e){let{keyCookieName:t,csrfCookieName:s}=(0,n.A)(),a=`${t}_su`;if(!e.cookies?.[a])return console.log("No auth key cookie found"),null;let o=(0,r.A)({encryptedString:e.cookies[a]});if(!o)return console.log("No user payload found"),null;let i=JSON.parse(o);return i.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):i.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):i}},92702:(e,t,s)=>{async function r(e,t,s){return Object(function(){var e=Error("Cannot find module '@moduletrace/datasquirel/dist/users/user-auth'");throw e.code="MODULE_NOT_FOUND",e}())({req:e,level:s?"deep":void 0}).payload}s.d(t,{A:()=>r}),function(){var e=Error("Cannot find module '@moduletrace/datasquirel/dist/users/user-auth'");throw e.code="MODULE_NOT_FOUND",e}()},89923:(e,t,s)=>{s.d(t,{A:()=>r});function r(e,t){return t?!!(e?.id&&String(e?.id)==(process.env.DSQL_SU_USER_ID||"1")):!!(e?.id&&"1"==String(e?.id))}},41939:(e,t,s)=>{s.d(t,{A:()=>r});function r(e){let t=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",r=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",n=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",a=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),o=t;e?.userId&&(o+=`user_${e.userId}_`),a&&(o+=`${a}_`),o+=s;let i=t;e?.userId&&(i+=`user_${e.userId}_`),a&&(i+=`${a}_`),i+=r;let l=t;return e?.userId&&(l+=`user_${e.userId}_`),a&&(l+=`${a}_`),{keyCookieName:o,csrfCookieName:i,oneTimeCodeName:l+=n}}},71205:(e,t,s)=>{s.d(t,{A:()=>o});var r=s(55511),n=s(79428),a=s(48243);function o({encryptedString:e,encryptionKey:t,encryptionSalt:s}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:o,salt:i,keyLen:l,algorithm:c,bufferAllocSize:u}=(0,a.A)({encryptionKey:t});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 d=(0,r.scryptSync)(o,i,l),p=n.Buffer.alloc(u,0),m=(0,r.createDecipheriv)(c,d,p);try{let t=m.update(e,"hex","utf8");return t+=m.final("utf8")}catch(t){return console.log("Error in decrypting =>",t.message),e}}},48243:(e,t,s)=>{s.d(t,{A:()=>r});function r(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?function(e,t){try{let t=Number(e);if("number"!=typeof t||isNaN(t))return 0;return Math.round(t)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},5583:(e,t,s)=>{s.r(t),s.d(t,{default:()=>a});var r=s(8732);s(82015);var n=s(20883);function a(){return(0,r.jsxs)(n.Html,{lang:"en",children:[(0,r.jsxs)(n.Head,{children:[(0,r.jsx)("meta",{name:"author",content:"Datasquirel"}),(0,r.jsx)("meta",{name:"Copyright",content:`Copyright (c) ${new Date().getFullYear()} Datasquirel`}),"dev_dev".match(/dev/)&&(0,r.jsx)("meta",{name:"robots",content:"noindex,nofollow"}),(0,r.jsx)("link",{rel:"preconnect",href:"https://fonts.googleapis.com/",crossOrigin:"anonymous"}),(0,r.jsx)("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),(0,r.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Poppins"}),(0,r.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Inter"}),(0,r.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=IBM+Plex+Mono"}),(0,r.jsx)("script",{src:"/scripts/themeSelector.js"}),(0,r.jsx)("meta",{httpEquiv:"Content-Type",content:"text/html; charset=UTF-8"}),(0,r.jsx)("meta",{property:"og:site_name",content:"DATASQUIREL"}),(0,r.jsx)("meta",{property:"og:type",content:"website"}),(0,r.jsx)("meta",{name:"twitter:card",content:"summary"}),(0,r.jsx)("meta",{property:"og:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,r.jsx)("meta",{itemProp:"image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,r.jsx)("meta",{name:"twitter:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,r.jsx)("link",{rel:"stylesheet",href:"/styles/prism.css"}),(0,r.jsx)("script",{src:"/scripts/prism.js",async:!0}),(0,r.jsx)("script",{dangerouslySetInnerHTML:{__html:"var DSQL = {}"}})]}),(0,r.jsxs)("body",{children:[(0,r.jsx)(n.Main,{}),(0,r.jsx)(n.NextScript,{})]})]})}},9455:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return s}});var s=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},13893:e=>{e.exports=require("@moduletrace/datasquirel/dist/client/fetch")},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")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},33873:e=>{e.exports=require("path")}};var t=require("../../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),r=t.X(0,[883,9821,9796],()=>s(38954));module.exports=r})(); |