16 lines
4.4 KiB
JavaScript
16 lines
4.4 KiB
JavaScript
"use strict";(()=>{var e={};e.id=536,e.ids=[536],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},9973:e=>{e.exports=require("serverless-mysql")},29021:e=>{e.exports=require("fs")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,s){return s in r?r[s]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,s)):"function"==typeof r&&"default"===s?r:void 0}}})},56625:(e,r,s)=>{s.r(r),s.d(r,{config:()=>_,default:()=>d,routeModule:()=>p});var t={};s.r(t),s.d(t,{default:()=>l});var n=s(89947),o=s(2706),i=s(96762),a=s(69842),u=s(67619),c=s(48786);async function l(e,r){if("POST"!==e.method)return r.json({user:null,msg:"Registration Failed!"});let s=await (0,a.A)(e,r,!0);if(!s)return r.json({success:!1,msg:"Unauthorized"});let{id:t}=e.body;try{let e=await (0,c.A)("SELECT * FROM mariadb_users WHERE id = ? AND user_id = ?",[t,s.id]),n=e?.[0];if(!n?.id)throw Error("Active User couldn't be verified");if(String(n.primary)?.match(/1/))throw Error("Cannot Delete Primary User");let o=n.username,i=n.host;await (0,c.A)("DELETE FROM mariadb_users WHERE user_id = ? AND id = ?",[s.id,n.id]),await (0,c.A)(`DROP USER '${o}'@'${i}'`),r.json({success:!0})}catch(e){(0,u.A)({component:"/api/acceptUserInvitation/catch-error",message:e.message,user:s}),r.json({success:!1,msg:"Error in adding SQL user =>"+e.message,err:e.message})}}let d=(0,i.M)(t,"default"),_=(0,i.M)(t,"config"),p=new n.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/sql-users/delete",pathname:"/api/sql-users/delete",bundlePath:"",filename:""},userland:t})},69842:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(39908),n=s.n(t);async function o(e,r,s){let t=n()({req:e,level:s?"deep":void 0});return console.log(t),t.payload}},67619:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(29021),n=s.n(t);async function o({user:e,message:r,component:s,noMail:t,req:o}){let i=new Date,a=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],s=o.headers["cf-connecting-ip"],t=Array.isArray(e)?e[0]:e?.split(",")[0],n=s||t||r||o.socket.remoteAddress;if(!n)return null;return String(n)}catch(e){return null}})();try{let t=`🚀 SERVER ERROR ===========================
|
|
Error Message: ${r}
|
|
Component: ${s}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(t+=`
|
|
User Id: ${e?.id}
|
|
User Name: ${e?.first_name} ${e?.last_name}
|
|
User Email: ${e?.email}`),o?.url&&(t+=`
|
|
URL: ${o.url}`),o?.body&&(t+=`
|
|
Request Body: ${JSON.stringify(o.body,null,4)}`),a&&(t+=`
|
|
IP: ${a}`),t+=`
|
|
Date: ${i.toDateString()}
|
|
========================================`,n().existsSync("./.tmp/error.log")||n().writeFileSync("./.tmp/error.log","","utf-8");let u=n().readFileSync("./.tmp/error.log","utf-8");n().writeFileSync("./.tmp/error.log",t),n().appendFileSync("./.tmp/error.log",`
|
|
|
|
|
|
|
|
|
|
${u}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},48786:(e,r,s)=>{s.d(r,{A:()=>n});var t=s(7447);async function n(...e){let r=(0,t.A)();try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let s=await r.query(...e);return JSON.parse(JSON.stringify(s))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},7447:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(9973),n=s.n(t);function o(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return s}});var s=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}({})},89947:(e,r,s)=>{e.exports=s(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var s=r(r.s=56625);module.exports=s})(); |