"use strict";(()=>{vare={};e.id=8935,e.ids=[8935],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")},27118:(e,r,t)=>{t.r(r),t.d(r,{config:()=>S,default:()=>v,routeModule:()=>h});vars={};t.r(s),t.d(s,{default:()=>g});vari=t(89947),a=t(2706),n=t(96762),l=t(6420),o=t.n(l),u=t(48225),d=t.n(u),_=t(27825),c=t.n(_),p=t(51348),m=t.n(p),f=t(47670),E=t.n(f);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lett=awaito()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});lets=c().cloneDeep(e.body),i=s.inviting_user_id,a=s.invited_user_email,n=s.database_access,l=s.priviledge;try{lete=awaitm()("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])returnr.json({success:!1});lets=awaitE()({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:i,invited_user_id:t.id,database_access:n,user_priviledge:l,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}});awaitm()("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[i,a]);leto=awaitm()("SELECT db_tables_data FROM invitations WHERE inviting_user_id=?",[i]);if(awaitm()(`DELETE FROM delegated_user_tables WHERE root_user_id='${i}' AND delegated_user_id='${t.id}'`),o&&o[0]){lete=o[0].db_tables_data.split("|");for(letr=0;r<e.length;r++){let[s,a]=e[r].split("-");awaitE()({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:t.id,root_user_id:i,database:s,table:a,priviledge:l}})}}r.json({success:!!s?.insertId})}catch(s){d()({component:"/api/acceptUserInvitation/catch-error",message:s.message,user:t,req:e}),r.json({success:!1})}}t(29021);letv=(0,n.M)(s,"default"),S=(0,n.M)(s,"config"),h=newi.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/acceptUserInvitation",pathname:"/api/acceptUserInvitation",bundlePath:"",filename:""},userland:s})},6420:(e,r,t)=>{t(81630);lets=t(51348),i=t(72835),a=t(29021),n=t(31341);asyncfunctionl(e,r,t,l){let{keyCookieName:o,csrfCookieName:u}=n();if(!e.cookies?.[o]?.match(/./))returnnull;letd=i({encryptedString:e.cookies[o]});if(!d)returnnull;let_=JSON.parse(d);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=awaits(`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},31341:e=>{e.exports=function(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",i=e?.database||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),i&&(a+=`${i}_`),a+=t;letn=r;returne?.userId&&(n+=`user_${e.userId}_`),i&&(n+=`${i}_`),{keyCookieName:a,csrfCookieName:n+=s}}},48225:(e,r,t)=>{lets=t(29021),{IncomingMessage:i}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:i,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"],s=Array.isArray(e)?e[0]:e?.split(",")[0],i=t||s||r||a.socket.remoteAddress;if(!i)returnnull;returnString(i)}catch(e){returnnull}})();try{leti=`🚀 SERVER ERROR ===========================