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

16 lines
3.7 KiB
JavaScript
Raw Normal View History

2025-01-14 15:27:08 +00:00
"use strict";(()=>{var e={};e.id=8935,e.ids=[8935],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},27825:e=>{e.exports=require("lodash")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},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")},34042:(e,r,t)=>{t.r(r),t.d(r,{config:()=>g,default:()=>p,routeModule:()=>f});var a={};t.r(a),t.d(a,{default:()=>_});var i=t(89947),s=t(2706),n=t(96762),l=t(69842),d=t(67619),u=t(27825),o=t.n(u),m=t(48786),c=t(98e3);async function _(e,r){if("POST"!==e.method)return r.json({user:null,msg:"Registration Failed!"});let t=await (0,l.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let a=o().cloneDeep(e.body),i=a.inviting_user_id,s=a.invited_user_email,n=a.database_access,u=a.priviledge;try{let e=await (0,m.A)("SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?",[i,t.id,t.email]);if(e&&e[0])return r.json({success:!1});let a=await (0,c.A)({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:i,invited_user_id:t.id,database_access:n,user_priviledge:u,user_type:"admin",first_name:t.first_name,last_name:t.last_name,email:t.email,username:t.first_name,image:t.image,image_thumbnail:t.image_thumbnail}});await (0,m.A)("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[i,s]);let l=await (0,m.A)("SELECT db_tables_data FROM invitations WHERE inviting_user_id=?",[i]);if(await (0,m.A)(`DELETE FROM delegated_user_tables WHERE root_user_id='${i}' AND delegated_user_id='${t.id}'`),l&&l[0]){let e=l[0].db_tables_data.split("|");for(let r=0;r<e.length;r++){let[a,s]=e[r].split("-");await (0,c.A)({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:t.id,root_user_id:i,database:a,table:s,priviledge:u}})}}r.json({success:!!a?.insertId})}catch(a){(0,d.A)({component:"/api/acceptUserInvitation/catch-error",message:a.message,user:t,req:e}),r.json({success:!1})}}let p=(0,n.M)(a,"default"),g=(0,n.M)(a,"config"),f=new i.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/acceptUserInvitation",pathname:"/api/acceptUserInvitation",bundlePath:"",filename:""},userland:a})},69842:(e,r,t)=>{t.d(r,{A:()=>s});var a=t(39908),i=t.n(a);async function s(e,r,t){let a=i()({req:e,level:t?"deep":void 0});return console.log(a),a.payload}},67619:(e,r,t)=>{t.d(r,{A:()=>s});var a=t(29021),i=t.n(a);async function s({user:e,message:r,component:t,noMail:a,req:s}){let n=new Date,l=(()=>{if(!s)return null;try{let e=s.headers["x-forwarded-for"],r=s.headers["x-real-ip"],t=s.headers["cf-connecting-ip"],a=Array.isArray(e)?e[0]:e?.split(",")[0],i=t||a||r||s.socket.remoteAddress;if(!i)return null;return String(i)}catch(e){return null}})();try{let a=`🚀 SERVER ERROR ===========================
2024-12-08 19:56:57 +00:00
Error Message: ${r}
2025-01-14 15:27:08 +00:00
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(a+=`
2024-12-08 19:56:57 +00:00
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
2025-01-14 15:27:08 +00:00
User Email: ${e?.email}`),s?.url&&(a+=`
URL: ${s.url}`),s?.body&&(a+=`
Request Body: ${JSON.stringify(s.body,null,4)}`),l&&(a+=`
IP: ${l}`),a+=`
2024-12-08 19:56:57 +00:00
Date: ${n.toDateString()}
2025-01-14 15:27:08 +00:00
========================================`,i().existsSync("./.tmp/error.log")||i().writeFileSync("./.tmp/error.log","","utf-8");let d=i().readFileSync("./.tmp/error.log","utf-8");i().writeFileSync("./.tmp/error.log",a),i().appendFileSync("./.tmp/error.log",`
2024-12-08 19:56:57 +00:00
2025-01-14 15:27:08 +00:00
${d}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[1251],()=>t(34042));module.exports=a})();