"use strict";(()=>{vare={};e.id=9785,e.ids=[9785],e.modules={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")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},81764:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>c,routeModule:()=>p});vari={};t.r(i),t.d(i,{default:()=>_});vars=t(89947),a=t(2706),n=t(96762),l=t(6420),o=t.n(l),d=t(44767),u=t.n(d);asyncfunction_(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaito()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});console.log("Invitation Received by current logged in user, Loggin in VIA API ...");leti=awaitu()({query:e.body.query,user:t});r.json({success:!0,result:i})}letc=(0,n.M)(i,"default"),m=(0,n.M)(i,"config"),p=news.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/addAdminUserUser",pathname:"/api/addAdminUserUser",bundlePath:"",filename:""},userland:i})},6420:(e,r,t)=>{t(81630);leti=t(51348),s=t(72835),a=t(29021),n=t(31341);asyncfunctionl(e,r,t,l){let{keyCookieName:o,csrfCookieName:d}=n();if(!e.cookies?.[o]?.match(/./))returnnull;letu=s({encryptedString:e.cookies[o]});if(!u)returnnull;let_=JSON.parse(u);if(!_.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${_.csrf_k}`)))returnnull;letc=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!c)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!a.existsSync(`${c}/${_.csrf_k}`))returnnull;if(0==_.verification_status&&!t){lete=awaiti(`SELECT verification_status FROM users WHERE id='${_.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}return_?.date&&Date.now()-_.date>6048e5?null:_}e.exports=l},44767:(e,r,t)=>{leti=t(48225),s=t(51348),a=t(47670);e.exports=asyncfunction({query:e,user:r}){try{let{invite:t,database_access:i,priviledge:n,email:l}=e,o=awaits("SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[t,l]);if(!o||!o[0])throwError("No Invitation Found");letd=awaits("SELECT first_name,last_name,email FROM users WHERE id=?",[t]);if(d?.[0]){lete=awaits("SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?",[t,r.id,l]);if(e?.[0])console.log("User already added");else{a({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:t,invited_user_id:r.id,database_access:i,first_name:r.first_name,last_name:r.last_name,phone:r.phone,email:r.email,username:r.username,user_type:"admin",user_priviledge:n,image:r.image,image_thumbnail:r.image_thumbnail}});lete=awaits("SELECT db_tables_data FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[t,l]);if(awaits("DELETE FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=?",[t,r.id]),e&&e[0]){leti=e[0].db_tables_data.split("|");for(lete=0;e<i.length;e++){let[s,l]=i[e].split("-");awaita({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:r.id,root_user_id:t,database:s,table:l,priviledge:n}})}}}awaits("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[t,l])}}catch(e){i({component:"addAdminUserOnLogin",message:e.message,user:r})}}},31341:e=>{e.exports=function(){lete=process.env.DSQL_COOKIES_PREFIX||"dsql_";return{keyCookieName:e+(process.env.DSQL_COOKIES_KEY_NAME||"key"),csrfCookieName:e+(process.env.DSQL_COOKIES_CSRF_NAME||"csrf")}}},48225:(e,r,t)=>{leti=t(29021),{IncomingMessage:s}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:s,req:a}){letn=newDate,l=(()=>{if(!a)returnnull;try{lete=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a.headers["cf-connecting-ip"],i=Array.isArray(e)?e[0]:e?.split(",")[0],s=t||i||r||a.socket.remoteAddress;if(!s)returnnull;returnString(s