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

1 line
9.4 KiB
JavaScript
Raw Normal View History

2024-12-05 07:03:33 +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:()=>E,default:()=>P,getServerSideProps:()=>v,getStaticPaths:()=>j,getStaticProps:()=>q,reportWebVitals:()=>A,routeModule:()=>w,unstable_getServerProps:()=>N,unstable_getServerSideProps:()=>L,unstable_getStaticParams:()=>k,unstable_getStaticPaths:()=>M,unstable_getStaticProps:()=>D});var s={};r.r(s),r.d(s,{default:()=>y,getServerSideProps:()=>_});var i=r(63865),a=r(9455),n=r(30671),o=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),b=r.n(S);function y({user:e,email:t,productionEnvironment:r,existingAlerts:s}){let i="Unsubscribe | Datasquirel",a="Unsubscribe from email alerts",n=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:i}),(0,l.jsx)("meta",{name:"description",content:a}),(0,l.jsx)(x.A,{pageTitle:i,pageDescription:a,pagePathname:"/unsubscribe"})]}),[o,u]=p().useState(!1);return(0,l.jsx)(p().Fragment,{children:(0,l.jsx)(g.A,{head:n,user:e,productionEnvironment:r,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: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 _({req:e,res:t,query:r}){let s=process.env.DSQL_HOST_ENV,i=await h()(e,t),a=r.email?r.email:i?.email?i.email:null,n=await b()(`SELECT email FROM unsubscribes WHERE email='${a}' AND type='alerts'`);return{props:{user:i,email:a,productionEnvironment:s,existingAlerts:!n[0]}}}let P=(0,n.M)(s,"default"),q=(0,n.M)(s,"getStaticProps"),j=(0,n.M)(s,"getStaticPaths"),v=(0,n.M)(s,"getServerSideProps"),E=(0,n.M)(s,"config"),A=(0,n.M)(s,"reportWebVitals"),D=(0,n.M)(s,"unstable_getStaticProps"),M=(0,n.M)(s,"unstable_getStaticPaths"),k=(0,n.M)(s,"unstable_getStaticParams"),N=(0,n.M)(s,"unstable_getServerProps"),L=(0,n.M)(s,"unstable_getServerSideProps"),w=new i.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/unsubscribe",pathname:"/unsubscribe",bundlePath:"",filename:""},components:{App:u.default,Document:o.default},userland:s})},20048:(e,t,r)=>{r(81630);let s=r(67216),i=r(83007),a=r(29021);async function n(e,t,r,n){if(!e.cookies?.datasquirelAuthKey?.match(/./))return null;let o=i(e.cookies.datasquirelAuthKey);if(!o)return null;let u=JSON.parse(o);if(!u.csrf_k||r&&!e.headers["x-csrf-auth"]?.match(RegExp(`${u.csrf_k}`)))return null;let l=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!l)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(r&&!a.existsSync(`${l}/${u.csrf_k}`))return null;if(0==u.verification_status&&!r){let e=await s(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}return u?.date&&Date.now()-u.date>6048e5?null:u}e.exports=n},83007:(e,t,r)=>{