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

1 line
10 KiB
JavaScript
Raw Normal View History

2024-12-06 13:24:26 +00:00
"use strict";(()=>{var e={};e.id=3751,e.ids=[636,3751],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}}})},76048:(e,t,r)=>{r.r(t),r.d(t,{config:()=>j,default:()=>P,getServerSideProps:()=>q,getStaticPaths:()=>E,getStaticProps:()=>v,reportWebVitals:()=>D,routeModule:()=>O,unstable_getServerProps:()=>k,unstable_getServerSideProps:()=>L,unstable_getStaticParams:()=>M,unstable_getStaticPaths:()=>N,unstable_getStaticProps:()=>A});var s={};r.r(s),r.d(s,{default:()=>b,getServerSideProps:()=>y});var i=r(63865),n=r(9455),o=r(30671),a=r(49407),u=r(68268),l=r(8732),c=r(82015),p=r.n(c),m=r(32415),x=r(87472),d=r(20048),h=r.n(d),f=r(63715),g=r(71457),S=r(67216),_=r.n(S);function b({user:e,email:t,productionEnvironment:r,existingAlerts:s}){let i="Unsubscribe | Datasquirel",n="Unsubscribe from email alerts",o=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:i}),(0,l.jsx)("meta",{name:"description",content:n}),(0,l.jsx)(x.A,{pageTitle:i,pageDescription:n,pagePathname:"/unsubscribe"})]}),[a,u]=p().useState(!1);return(0,l.jsx)(p().Fragment,{children:(0,l.jsx)(g.A,{head:o,user:e,productionEnvironment:r,children:(0,l.jsx)("main",{children:(0,l.jsxs)("section",{children:[a&&(0,l.jsx)(m.A,{}),(0,l.jsxs)("div",{className:"flex-col",children:[(0,l.jsx)("h1",{className:"text-2xl",children:"Unsubscribe from Email alerts"}),!t&&(0,l.jsxs)("p",{className:"max-w-md",children:["No email please ",(0,l.jsx)("a",{href:"/login",children:"Login"})," ","to Access Email Subscriptions or click on"," ",(0,l.jsx)("i",{children:'"unsubscribe"'})," from your mail box"]}),t&&(0,l.jsxs)("form",{className:"flex flex-col items-start gap-4",onSubmit:r=>{r.preventDefault(),u(!0);let s=r.target;(0,f.A)("/api/unsubscribe",{method:"post",body:{email:t,alerts:s.alerts_checkbox.checked,userId:e?.id?e.id:null}}).then(e=>{console.log(e),u(!1)})},children:[(0,l.jsx)("span",{className:"bg-slate-100 py-1 px-3 rounded-full",children:t}),(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)("input",{type:"checkbox",name:"alerts_checkbox",id:"alerts_checkbox",defaultChecked:!!s,className:"w-6 h-6"}),(0,l.jsx)("label",{htmlFor:"alerts_checkbox",className:"text-base whitespace-nowrap text-slate-800",children:"Alerts"})]}),(0,l.jsx)("button",{children:"Save Settings"})]})]})]})})})})}async function y({req:e,res:t,query:r}){let s=process.env.DSQL_HOST_ENV,i=await h()(e,t),n=r.email?r.email:i?.email?i.email:null,o=await _()(`SELECT email FROM unsubscribes WHERE email='${n}' AND type='alerts'`);return{props:{user:i,email:n,productionEnvironment:s,existingAlerts:!o[0]}}}let P=(0,o.M)(s,"default"),v=(0,o.M)(s,"getStaticProps"),E=(0,o.M)(s,"getStaticPaths"),q=(0,o.M)(s,"getServerSideProps"),j=(0,o.M)(s,"config"),D=(0,o.M)(s,"reportWebVitals"),A=(0,o.M)(s,"unstable_getStaticProps"),N=(0,o.M)(s,"unstable_getStaticPaths"),M=(0,o.M)(s,"unstable_getStaticParams"),k=(0,o.M)(s,"unstable_getServerProps"),L=(0,o.M)(s,"unstable_getServerSideProps"),O=new i.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/unsubscribe",pathname:"/unsubscribe",bundlePath:"",filename:""},components:{App:u.default,Document:a.default},userland:s})},20048:(e,t,r)=>{r(81630);let s=r(67216),i=r(77463),n=r(29021),o=r(6505);async function a(e,t,r,a){let{keyCookieName:u,csrfCookieName:l}=o();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&&!n.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>6048