dsql-admin/dsql-app/.local_dist/server/pages/unsubscribe.js
Benjamin Toby 1564c2811a Updates
2025-01-14 08:24:54 +01:00

1 line
9.9 KiB
JavaScript

"use strict";(()=>{var e={};e.id=3751,e.ids=[3220,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}}})},41531:(e,t,r)=>{r.r(t),r.d(t,{config:()=>P,default:()=>S,getServerSideProps:()=>E,getStaticPaths:()=>y,getStaticProps:()=>b,reportWebVitals:()=>v,routeModule:()=>w,unstable_getServerProps:()=>O,unstable_getServerSideProps:()=>k,unstable_getStaticParams:()=>D,unstable_getStaticPaths:()=>N,unstable_getStaticProps:()=>A});var s={};r.r(s),r.d(s,{default:()=>_,getServerSideProps:()=>j});var n=r(63865),a=r(9455),i=r(30671),o=r(5583),c=r(19796),l=r(8732),u=r(82015),p=r.n(u),m=r(16757),d=r(91258),h=r(92702),x=r(46169),f=r(1013),g=r(71934);function _({user:e,email:t,productionEnvironment:r,existingAlerts:s}){let n="Unsubscribe | Datasquirel",a="Unsubscribe from email alerts",i=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("title",{children:n}),(0,l.jsx)("meta",{name:"description",content:a}),(0,l.jsx)(d.A,{pageTitle:n,pageDescription:a,pagePathname:"/unsubscribe"})]}),[o,c]=p().useState(!1);return(0,l.jsx)(p().Fragment,{children:(0,l.jsx)(f.A,{head:i,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(),c(!0);let s=r.target;(0,x.A)("/api/unsubscribe",{method:"post",body:{email:t,alerts:s.alerts_checkbox.checked,userId:e?.id?e.id:null}}).then(e=>{console.log(e),c(!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 j({req:e,res:t,query:r}){let s=process.env.DSQL_HOST_ENV,n=await (0,h.A)(e,t),a=r.email?r.email:n?.email?n.email:null,i=await (0,g.A)(`SELECT email FROM unsubscribes WHERE email='${a}' AND type='alerts'`);return{props:{user:n,email:a,productionEnvironment:s,existingAlerts:!i[0]}}}let S=(0,i.M)(s,"default"),b=(0,i.M)(s,"getStaticProps"),y=(0,i.M)(s,"getStaticPaths"),E=(0,i.M)(s,"getServerSideProps"),P=(0,i.M)(s,"config"),v=(0,i.M)(s,"reportWebVitals"),A=(0,i.M)(s,"unstable_getStaticProps"),N=(0,i.M)(s,"unstable_getStaticPaths"),D=(0,i.M)(s,"unstable_getStaticParams"),O=(0,i.M)(s,"unstable_getServerProps"),k=(0,i.M)(s,"unstable_getServerSideProps"),w=new n.PagesRouteModule({definition:{kind:a.A.PAGES,page:"/unsubscribe",pathname:"/unsubscribe",bundlePath:"",filename:""},components:{App:c.default,Document:o.default},userland:s})},91258:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(8732),n=r(82015),a=r.n(n);function i({pageTitle:e,pageDescription:t,pagePathname:r,aceEditor:n}){return(0,s.jsxs)(a().Fragment,{children:[(0,s.jsx)("link",{rel:"canonical",href:"http://localhost:7070"+r}),(0,s.jsx)("meta",{property:"og:url",content:"http://localhost:7070"+r}),(0,s.jsx)("meta",{itemProp:"url",content:"http://localhost:7070"+r}),(0,s.jsx)("meta",{name:"twitter:url",content:"http://localhost:7070"+r}),(0,s.jsx)("meta",{property:"og:title",content:e}),(0,s.jsx)("meta",{property:"og:description",content:t}),(0,s.jsx)("meta",{itemProp:"name",content:e}),(0,s.jsx)("meta",{itemProp:"description",content:t}),(0,s.jsx)("meta",{name:"twitter:title",content:e}),(0,s.jsx)("meta",{name:"twitter:description",content:t}),n&&(0,s.jsxs)(a().Fragment,{children:[(0,s.jsx)("script",{src:"https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ace.min.js",integrity:"sha512-q6CTB0jS+VuJnSct82rVcWlI06LGzNjaG3CWenHWVUncRvc4UQMFkA3a5Ip880xr+lBx38FcHDclOxPdSg+sBw==",crossOrigin:"anonymous",referrerPolicy:"no-referrer"}),(0,s.jsx)("script",{src:"https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ext-language_tools.min.js",integrity:"sha512-6g6cvocV7eT/J8L44lL8gJKqq9onqQeYGgJO0DmrsYFcCfRl6wYkYA/KHS768r4QVTB4JxsCcMQ9gIezxpTCZw==",crossOrigin:"anonymous",referrerPolicy:"no-referrer"})]})]})}},92702:(e,t,r)=>{r.d(t,{A:()=>c});var s=r(71934),n=r(71205),a=r(29021),i=r.n(a),o=r(41939);async function c(e,t,r){try{let{keyCookieName:a,csrfCookieName:c}=(0,o.A)();if(!e.cookies?.[a]?.match(/./))throw Error("Request Cookies not Found!");let l=(0,n.A)({encryptedString:e.cookies[a]});if(!l)throw Error("Couldn't decrypt auth cookie!");let u=JSON.parse(l);if(!u.csrf_k)throw Error("No `csrf_k` present in user Object!");if(r&&!Object.keys(e.headers).find(e=>e.includes(u.csrf_k)))throw Error("Deep Auth Failed. `csrf` key not found in request headers!");let p=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!p)throw Error("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(r&&!i().existsSync(`${p}/${u.csrf_k}`))throw Error("Key not found in Auth Keys Folder!");if(0==u.verification_status&&!r){let e=await (0,s.A)(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}if(u?.date&&Date.now()-u.date>6048e5)throw Error("Key expired!");return u}catch(t){return console.log(`userAuth Error for ${e.url}: ${t.message}`),null}}},41939:(e,t,r)=>{r.d(t,{A:()=>s});function s(e){let t=process.env.DSQL_COOKIES_PREFIX||"dsql_",r=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",n=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",a=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),i=t;e?.userId&&(i+=`user_${e.userId}_`),a&&(i+=`${a}_`),i+=r;let o=t;e?.userId&&(o+=`user_${e.userId}_`),a&&(o+=`${a}_`),o+=s;let c=t;return e?.userId&&(c+=`user_${e.userId}_`),a&&(c+=`${a}_`),{keyCookieName:i,csrfCookieName:o,oneTimeCodeName:c+=n}}},71205:(e,t,r)=>{r.d(t,{A:()=>a});var s=r(55511),n=r(79428);function a({encryptedString:e,encryptionKey:t,encryptionSalt:r}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let a=t||process.env.DSQL_ENCRYPTION_PASSWORD,i=r||process.env.DSQL_ENCRYPTION_SALT,o=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!a?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let c=(0,s.scryptSync)(a,i,o),l=n.Buffer.alloc(16,0),u=(0,s.createDecipheriv)("aes-192-cbc",c,l);try{let t=u.update(e,"hex","utf8");return t+=u.final("utf8")}catch(t){return console.log("Error in decrypting =>",t.message),e}}},71934:(e,t,r)=>{r.d(t,{A:()=>s});async function s(...e){let t=global.DSQL_DB_CONN;try{if(!t)throw Error("No Connection provided to DB_HANDLER function!");let r=await t.query(...e);return JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await t?.end()}}},5583:(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var s=r(8732);r(82015);var n=r(20883);function a(){return(0,s.jsxs)(n.Html,{lang:"en",children:[(0,s.jsxs)(n.Head,{children:[(0,s.jsx)("meta",{name:"author",content:"Datasquirel"}),(0,s.jsx)("meta",{name:"Copyright",content:`Copyright (c) ${new Date().getFullYear()} Datasquirel`}),"dev_dev".match(/dev/)&&(0,s.jsx)("meta",{name:"robots",content:"noindex,nofollow"}),(0,s.jsx)("link",{rel:"preconnect",href:"https://fonts.googleapis.com/",crossOrigin:"anonymous"}),(0,s.jsx)("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Poppins"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Inter"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=IBM+Plex+Mono"}),(0,s.jsx)("script",{src:"/scripts/themeSelector.js"}),(0,s.jsx)("meta",{httpEquiv:"Content-Type",content:"text/html; charset=UTF-8"}),(0,s.jsx)("meta",{property:"og:site_name",content:"DATASQUIREL"}),(0,s.jsx)("meta",{property:"og:type",content:"website"}),(0,s.jsx)("meta",{name:"twitter:card",content:"summary"}),(0,s.jsx)("meta",{property:"og:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("meta",{itemProp:"image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("meta",{name:"twitter:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("link",{rel:"stylesheet",href:"/styles/prism.css"}),(0,s.jsx)("script",{src:"/scripts/prism.js",async:!0}),(0,s.jsx)("script",{dangerouslySetInnerHTML:{__html:"var DSQL = {}"}})]}),(0,s.jsxs)("body",{children:[(0,s.jsx)(n.Main,{}),(0,s.jsx)(n.NextScript,{})]})]})}},9455:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}});var r=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},13893:e=>{e.exports=require("@moduletrace/datasquirel/dist/client/fetch")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},8732:e=>{e.exports=require("react/jsx-runtime")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")}};var t=require("../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[883,9821,9796],()=>r(41531));module.exports=s})();