1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
|
"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,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}}})},76048:(e,t,s)=>{s.r(t),s.d(t,{config:()=>j,default:()=>P,getServerSideProps:()=>q,getStaticPaths:()=>E,getStaticProps:()=>v,reportWebVitals:()=>D,routeModule:()=>k,unstable_getServerProps:()=>L,unstable_getServerSideProps:()=>O,unstable_getStaticParams:()=>M,unstable_getStaticPaths:()=>N,unstable_getStaticProps:()=>A});var r={};s.r(r),s.d(r,{default:()=>b,getServerSideProps:()=>y});var i=s(63865),n=s(9455),a=s(30671),o=s(49407),u=s(68268),l=s(8732),c=s(82015),p=s.n(c),m=s(32415),x=s(87472),d=s(20048),h=s.n(d),f=s(63715),g=s(71457),S=s(67216),_=s.n(S);function b({user:e,email:t,productionEnvironment:s,existingAlerts:r}){let i="Unsubscribe | Datasquirel",n="Unsubscribe from email alerts",a=(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"})]}),[o,u]=p().useState(!1);return(0,l.jsx)(p().Fragment,{children:(0,l.jsx)(g.A,{head:a,user:e,productionEnvironment:s,children:(0,l.jsx)("main",{children:(0,l.jsxs)("section",{children:[o&&(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:s=>{s.preventDefault(),u(!0);let r=s.target;(0,f.A)("/api/unsubscribe",{method:"post",body:{email:t,alerts:r.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:!!r,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:s}){let r=process.env.DSQL_HOST_ENV,i=await h()(e,t),n=s.email?s.email:i?.email?i.email:null,a=await _()(`SELECT email FROM unsubscribes WHERE email='${n}' AND type='alerts'`);return{props:{user:i,email:n,productionEnvironment:r,existingAlerts:!a[0]}}}let P=(0,a.M)(r,"default"),v=(0,a.M)(r,"getStaticProps"),E=(0,a.M)(r,"getStaticPaths"),q=(0,a.M)(r,"getServerSideProps"),j=(0,a.M)(r,"config"),D=(0,a.M)(r,"reportWebVitals"),A=(0,a.M)(r,"unstable_getStaticProps"),N=(0,a.M)(r,"unstable_getStaticPaths"),M=(0,a.M)(r,"unstable_getStaticParams"),L=(0,a.M)(r,"unstable_getServerProps"),O=(0,a.M)(r,"unstable_getServerSideProps"),k=new i.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/unsubscribe",pathname:"/unsubscribe",bundlePath:"",filename:""},components:{App:u.default,Document:o.default},userland:r})},20048:(e,t,s)=>{s(81630);let r=s(67216),i=s(77463),n=s(29021),a=s(6505);async function o(e,t,s,o){let{keyCookieName:u,csrfCookieName:l}=a();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||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&&!n.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>6048
|