"use strict";(()=>{vare={};e.id=2350,e.ids=[2350],e.modules={27825:e=>{e.exports=require("lodash")},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")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},46849:(e,r,t)=>{t.r(r),t.d(r,{config:()=>y,default:()=>g,routeModule:()=>R});vars={};t.r(s),t.d(s,{default:()=>_});varn=t(89947),o=t(2706),i=t(96762),a=t(6420),l=t.n(a),u=t(77538),c=t.n(u);t(27825);vard=t(51348),p=t.n(d),f=t(33873),S=t.n(f),m=t(79646),E=t(82703),h=t.n(E);asyncfunction_(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lett=awaitl()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{data:s,edit:n,prev:o,grants:i}=e.body;try{if(!o?.id)throwError("Invalid existing DB entry");lete=awaitp()("SELECT * FROM mariadb_users WHERE id = ? AND user_id = ?",[o.id,t.id]),n=e?.[0];if(!n?.id)throwError("Active User couldn't be verified");leta=`dsql_user_${t.id}`,{host:l,password:u}=s;if(!l)throwError("No host provided");if(l.match(/^%$/))throwError("Cannot set a catch-all host for this user.");letc=String(l).replace(/[^a-zA-Z0-9-\.\:\/\%]/g,"");if(n.host!=s.host){lete=awaitp()("SELECT * FROM mariadb_users WHERE user_id = ? AND host = ?",[t.id,c]);if(e?.[0]?.id)throwError("User already exists with this host. Please choose another host.");awaitp()(`RENAME USER '${a}'@'${n.host}' TO '${a}'@'${c}'`)}letd=h()(u),f=d==n.password?n.password:d;awaitp()("UPDATE mariadb_users SET host = ?, password = ?, grants = ? WHERE id = ?",[c,f,JSON.stringify(i),n.id]),awaitp()(`SET PASSWORD FOR '${a}'@'${c}' = PASSWORD('${u}');`);letE=S().resolve(process.cwd(),"./shell/mariadb-users");(0,m.execSync)(`node refreshUsersAndGrants.js --userId ${t.id} --username ${a} --host ${c} --sql-user-id ${n.id}}`,{cwd:E}),r.json({success:!0})}catch(e){c()({component:"/api/acceptUserInvitation/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Error in adding SQL user =>"+e.message,err:e.message})}}t(29021);letg=(0,i.M)(s,"default"),y=(0,i.M)(s,"config"),R=newn.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/sql-users/update",pathname:"/api/sql-users/update",bundlePath:"",filename:""},userland:s})},77538:(e,r,t)=>{lets=t(29021),{IncomingMessage:n}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:n,req:o}){leti=newDate,a=(()=>{if(!o)returnnull;try{lete=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],n=t||s||r||o.socket.remoteAddress;if(!n)returnnull;returnString(n)}catch(e){returnnull}})();try{letn=`🚀 SERVER ERROR ===========================