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

1 line
8.2 KiB
JavaScript
Raw Normal View History

2024-12-09 09:39:09 +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,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}}})},9247:(e,t,s)=>{s.r(t),s.d(t,{config:()=>D,default:()=>y,getServerSideProps:()=>b,getStaticPaths:()=>E,getStaticProps:()=>j,reportWebVitals:()=>A,routeModule:()=>k,unstable_getServerProps:()=>I,unstable_getServerSideProps:()=>M,unstable_getStaticParams:()=>N,unstable_getStaticPaths:()=>O,unstable_getStaticProps:()=>L});var r={};s.r(r),s.d(r,{default:()=>P,getServerSideProps:()=>v});var n=s(63865),a=s(9455),o=s(30671),i=s(49407),c=s(89600),l=s(8732),u=s(82015),p=s.n(u),m=s(27912),d=s.n(m),g=s(29021),f=s.n(g);s(63715),s(76601);var _=s(32415),h=s(6505),x=s.n(h);let S=s(20048);function P({user:e,query:t}){let s=(0,l.jsxs)(p().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)(p().Fragment,{children:[(0,l.jsx)(d(),{children:s}),(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 v({req:e,res:t,query:s}){let r=await S(e,t);if(r){console.log(r.csrf_k);try{let e=process.env.DSQL_USER_LOGIN_KEYS_PATH,t=`${e}/${r.csrf_k}`;console.log("allowedAuthKeyPath",t),f().unlinkSync(t)}catch(e){console.log(`Logout API error: ${e.message}`)}}let{keyCookieName:n,csrfCookieName:a}=x()();return t.setHeader("Set-Cookie",[`${n}=none;max-age=0`,`${a}=null;max-age=0`]),{props:{user:r,logged_out:!0,query:s}}}let y=(0,o.M)(r,"default"),j=(0,o.M)(r,"getStaticProps"),E=(0,o.M)(r,"getStaticPaths"),b=(0,o.M)(r,"getServerSideProps"),D=(0,o.M)(r,"config"),A=(0,o.M)(r,"reportWebVitals"),L=(0,o.M)(r,"unstable_getStaticProps"),O=(0,o.M)(r,"unstable_getStaticPaths"),N=(0,o.M)(r,"unstable_getStaticParams"),I=(0,o.M)(r,"unstable_getServerProps"),M=(0,o.M)(r,"unstable_getServerSideProps"),k=new n.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/logout",pathname:"/logout",bundlePath:"",filename:""},components:{App:c.default,Document:i.default},userland:r})},20048:(e,t,s)=>{s(81630);let r=s(67216),n=s(77463),a=s(29021),o=s(6505);async function i(e,t,s,i){let{keyCookieName:c,csrfCookieName:l}=o();if(!e.cookies?.[c]?.match(/./))return null;let u=n({encryptedString:e.cookies[c]});if(!u)return null;let p=JSON.parse(u);if(!p.csrf_k||s&&!e.headers["x-csrf-auth"]?.match(RegExp(`${p.csrf_k}`)))return null;let m=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!m)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(s&&!a.existsSync(`${m}/${p.csrf_k}`))return null;if(0==p.verification_status&&!s){let e=await r(`SELECT verification_status FROM users WHERE id='${p.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}return p?.date&&Date.now()-p.date>6048e5?null:p}e.exports=i},76601:(e,t,s)=>{s.d(t,{A:()=>r});async function r(){try{let e=await caches.keys();e[0]&&await Promise.all(e.map(e=>caches.delete(e)))}catch(e){console.log("Error in clearing cache =>",e.message)}}},6505:e=>{e.exports=function(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=t;e?.userId&&(n+=`user_${e.userId}_`),e?.database&&(n+=`${