dsql-admin/dsql-app/.local_dist/server/pages/logout.js

1 line
8.4 KiB
JavaScript
Raw Normal View History

2025-01-14 06:42:13 +00:00
"use strict";(()=>{var e={};e.id=7122,e.ids=[3220,7122],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}}})},92192:(e,t,r)=>{r.r(t),r.d(t,{config:()=>A,default:()=>E,getServerSideProps:()=>v,getStaticPaths:()=>j,getStaticProps:()=>P,reportWebVitals:()=>b,routeModule:()=>k,unstable_getServerProps:()=>I,unstable_getServerSideProps:()=>L,unstable_getStaticParams:()=>D,unstable_getStaticPaths:()=>O,unstable_getStaticProps:()=>N});var s={};r.r(s),r.d(s,{default:()=>S,getServerSideProps:()=>y});var n=r(63865),o=r(9455),a=r(30671),i=r(5583),c=r(19796),l=r(8732),u=r(82015),d=r.n(u),p=r(27912),m=r.n(p),g=r(29021),h=r.n(g),f=r(92702);r(46169),r(45731);var _=r(16757),x=r(41939);function S({user:e,query:t}){let r=(0,l.jsxs)(d().Fragment,{children:[(0,l.jsx)("title",{children:"Loging Out | Datasquirel"}),(0,l.jsx)("meta",{name:"description",content:"Login you out"}),(0,l.jsx)("script",{src:"https://accounts.google.com/gsi/client"}),(0,l.jsx)("script",{src:"https://connect.facebook.net/en_US/sdk.js",crossOrigin:"anonymous"})]});return(0,l.jsxs)(d().Fragment,{children:[(0,l.jsx)(m(),{children:r}),(0,l.jsx)("main",{className:"w-screen h-screen flex items-center justify-center p-4 md:p-8",children:(0,l.jsxs)("div",{className:"card max-w-md flex-col items-center bg-white p-6 rounded border border-slate-200 border-solid",children:[(0,l.jsxs)("a",{href:"/",className:"flex items-center gap-2",children:[(0,l.jsx)("img",{src:"/images/logo-icon-alt-2.png",alt:"Logo Icon",width:37}),(0,l.jsx)("span",{className:"font-bold text-2xl",children:"Datasquirel"})]}),(0,l.jsx)("h3",{className:"text-lg m-0 mt-4 text-slate-400",children:"Logging out"}),(0,l.jsx)(_.A,{position:"relative",width:"20px"})]})})]})}async function y({req:e,res:t,query:r}){let s=await (0,f.A)(e,t);if(s){console.log(s.csrf_k);try{let e=process.env.DSQL_USER_LOGIN_KEYS_PATH,t=`${e}/${s.csrf_k}`;console.log("allowedAuthKeyPath",t),h().unlinkSync(t)}catch(e){console.log(`Logout API error: ${e.message}`)}}let{keyCookieName:n,csrfCookieName:o}=(0,x.A)();return t.setHeader("Set-Cookie",[`${n}=none;max-age=0`,`${o}=null;max-age=0`]),{props:{user:s,logged_out:!0,query:r}}}let E=(0,a.M)(s,"default"),P=(0,a.M)(s,"getStaticProps"),j=(0,a.M)(s,"getStaticPaths"),v=(0,a.M)(s,"getServerSideProps"),A=(0,a.M)(s,"config"),b=(0,a.M)(s,"reportWebVitals"),N=(0,a.M)(s,"unstable_getStaticProps"),O=(0,a.M)(s,"unstable_getStaticPaths"),D=(0,a.M)(s,"unstable_getStaticParams"),I=(0,a.M)(s,"unstable_getServerProps"),L=(0,a.M)(s,"unstable_getServerSideProps"),k=new n.PagesRouteModule({definition:{kind:o.A.PAGES,page:"/logout",pathname:"/logout",bundlePath:"",filename:""},components:{App:c.default,Document:i.default},userland:s})},92702:(e,t,r)=>{r.d(t,{A:()=>c});var s=r(71934),n=r(71205),o=r(29021),a=r.n(o),i=r(41939);async function c(e,t,r){try{let{keyCookieName:o,csrfCookieName:c}=(0,i.A)();if(!e.cookies?.[o]?.match(/./))throw Error("Request Cookies not Found!");let l=(0,n.A)({encryptedString:e.cookies[o]});if(!l)throw Error("Couldn't decrypt auth cookie!");let u=JSON.parse(l);if(!u.csrf_k)throw Error("No `csrf_k` present in user Object!");if(r&&!Object.keys(e.headers).find(e=>e.includes(u.csrf_k)))throw console.log("req.headers",e.headers),console.log("userObject",u),Error("Deep Auth Failed. `csrf` key not found in request headers!");let d=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)throw Error("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(r&&!a().existsSync(`${d}/${u.csrf_k}`))throw Error("Key not found in Auth Keys Folder!");if(0==u.verification_status&&!r){let e=await (0,s.A)(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}if(u?.date&&Date.now()-u.date>6048e5)throw Error("Key expired!");return u}catch(e){return console.log(`userAuth Error: ${e.message}`),null}}},45731:(e,t,r)=>{r.d(t,{A:()=>s});async