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

1 line
9.8 KiB
JavaScript
Raw Normal View History

2024-12-06 13:24:26 +00:00
"use strict";(()=>{var e={};e.id=7122,e.ids=[636,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}}})},9247:(e,t,r)=>{r.r(t),r.d(t,{config:()=>b,default:()=>q,getServerSideProps:()=>j,getStaticPaths:()=>E,getStaticProps:()=>v,reportWebVitals:()=>D,routeModule:()=>k,unstable_getServerProps:()=>O,unstable_getServerSideProps:()=>M,unstable_getStaticParams:()=>N,unstable_getStaticPaths:()=>L,unstable_getStaticProps:()=>A});var s={};r.r(s),r.d(s,{default:()=>y,getServerSideProps:()=>P});var i=r(63865),o=r(9455),n=r(30671),a=r(49407),u=r(68268),l=r(8732),c=r(82015),p=r.n(c),m=r(27912),x=r.n(m),d=r(29021),g=r.n(d);r(63715),r(76601);var f=r(32415),h=r(6505),S=r.n(h);let _=r(20048);function y({user:e,query:t}){let r=(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)(x(),{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)(f.A,{position:"relative",width:"20px"})]})})]})}async function P({req:e,res:t,query:r}){let s=await _(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),g().unlinkSync(t)}catch(e){console.log(`Logout API error: ${e.message}`)}}let{keyCookieName:i,csrfCookieName:o}=S()();return t.setHeader("Set-Cookie",[`${i}=none;max-age=0`,`${o}=null;max-age=0`]),{props:{user:s,logged_out:!0,query:r}}}let q=(0,n.M)(s,"default"),v=(0,n.M)(s,"getStaticProps"),E=(0,n.M)(s,"getStaticPaths"),j=(0,n.M)(s,"getServerSideProps"),b=(0,n.M)(s,"config"),D=(0,n.M)(s,"reportWebVitals"),A=(0,n.M)(s,"unstable_getStaticProps"),L=(0,n.M)(s,"unstable_getStaticPaths"),N=(0,n.M)(s,"unstable_getStaticParams"),O=(0,n.M)(s,"unstable_getServerProps"),M=(0,n.M)(s,"unstable_getServerSideProps"),k=new i.PagesRouteModule({definition:{kind:o.A.PAGES,page:"/logout",pathname:"/logout",bundlePath:"",filename:""},components:{App:u.default,Document:a.default},userland:s})},20048:(e,t,r)=>{r(81630);let s=r(67216),i=r(77463),o=r(29021),n=r(6505);async function a(e,t,r,a){let{keyCookieName:u,csrfCookieName:l}=n();if(!e.cookies?.[u]?.match(/./))return null;let c=i({encryptedString:e.cookies[u]});if(!c)return null;let p=JSON.parse(c);if(!p.csrf_k||r&&!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(r&&!o.existsSync(`${m}/${p.csrf_k}`))return null;if(0==p.verification_status&&!r){let e=await s(`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=a},76601:(e,t,r)=>{r.d(t,{A:()=>s});async function s(){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(){let e=process.env.DSQL_COOKIES_PREFIX||"dsql_";return{keyCookieName:e+(process.env.DSQL_COOKIES_KEY_NAME||"key"),csrfCookieName:e+(process.env.DSQL_COOKIES_CSRF_NAME||"csrf")}}},77463:(e,t,r)=>{let