dsql-admin/dsql-app/.local_dist/server/pages/api/deleteUserUser.js

1 line
3.6 KiB
JavaScript
Raw Normal View History

2024-12-05 07:03:33 +00:00
"use strict";(()=>{var e={};e.id=3462,e.ids=[3462],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},96762:(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}}})},83246:(e,t,r)=>{r.r(t),r.d(t,{config:()=>f,default:()=>_,routeModule:()=>p});var s={};r.r(s),r.d(s,{default:()=>d});var n=r(89947),i=r(2706),a=r(96762),o=r(51348),u=r.n(o),c=r(6420),l=r.n(c);async function d(e,t){if("POST"!==e.method)return t.json({msg:"Failed!"});let r=await l()(e,t,!0);if(!r)return t.json({success:!1,msg:"Unauthorized"});let s=e.body,{user_type:n,user_id:i,email:a,invited_user_id:o}=s;await u()("DELETE FROM user_users WHERE id=?",[s.id]),n?.match(/admin/i)&&(await u()("DELETE FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[r.id,a]),await u()("DELETE FROM delegated_user_tables WHERE delegated_user_id=? AND root_user_id=?",[o,r.id])),t.json({success:!0,msg:"User Deleted!"})}r(29021);let _=(0,a.M)(s,"default"),f=(0,a.M)(s,"config"),p=new n.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/deleteUserUser",pathname:"/api/deleteUserUser",bundlePath:"",filename:""},userland:s})},6420:(e,t,r)=>{r(81630);let s=r(51348),n=r(72907),i=r(29021);async function a(e,t,r,a){if(!e.cookies?.datasquirelAuthKey?.match(/./))return null;let o=n(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 c=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!c)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(r&&!i.existsSync(`${c}/${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=a},72907:(e,t,r)=>{let{scryptSync:s,createDecipheriv:n}=r(55511),{Buffer:i}=r(79428);e.exports=e=>{let t=n("aes-192-cbc",s(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),i.alloc(16,0));try{let r=t.update(e,"hex","utf8");return r+=t.final("utf8")}catch(e){return null}}},51348:(e,t,r)=>{let s=r(9973),n=r(21580),i=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:n()}});async function a(...e){try{let t=await i.query(...e);return await i.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=a},21580:(e,t,r)=>{let s=r(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let t=`${e}/ca-cert.pem`;if(!s.existsSync(t)){console.log(`${t} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},2706:(e,t)=>{var r;Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(r||(r={}))},89947:(e,t,r)=>{e.exports=r(75600)}};var t=require("../../webpack-api-runtime.js");t.C(e);var r=t(t.s=83246);module.exports=r})();