"use strict";(()=>{vare={};e.id=2350,e.ids=[2350],e.modules={60818:e=>{e.exports=require("dotenv")},47795:e=>{e.exports=require("generate-password")},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")},46849:(e,r,s)=>{s.r(r),s.d(r,{config:()=>q,default:()=>w,routeModule:()=>x});vart={};s.r(t),s.d(t,{default:()=>g});vari=s(89947),a=s(2706),o=s(96762),d=s(6420),u=s.n(d),n=s(48225),l=s.n(n);s(27825);varp=s(51348),h=s.n(p);s(33873),s(79646);varc=s(20503),m=s.n(c),E=s(46889),f=s.n(E);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lets=awaitu()(e,r,!0);if(!s)returnr.json({success:!1,msg:"Unauthorized"});let{data:t,edit:i,prev:a,grants:o}=e.body;try{if(!a?.id)throwError("Invalid existing DB entry");lete=awaith()("SELECT * FROM mariadb_users WHERE id = ? AND user_id = ?",[a.id,s.id]),i=e?.[0];if(!i?.id)throwError("Active User couldn't be verified");letd=`dsql_user_${s.id}`,{host:u,password:n}=t;if(!u)throwError("No host provided");if(u.match(/^%$/))throwError("Cannot set a catch-all host for this user.");letl=String(u).replace(/[^a-zA-Z0-9-\.\:\/\%]/g,"");if(i.host!=t.host){lete=awaith()("SELECT * FROM mariadb_users WHERE user_id = ? AND host = ?",[s.id,l]);if(e?.[0]?.id)throwError("User already exists with this host. Please choose another host.");awaith()(`RENAME USER '${d}'@'${i.host}' TO '${d}'@'${l}'`)}letp=m()({data:n}),c=p==i.password?i.password:p;awaith()("UPDATE mariadb_users SET host = ?, password = ?, grants = ? WHERE id = ?",[l,c,JSON.stringify(o),i.id]),awaith()(`SET PASSWORD FOR '${d}'@'${l}' = PASSWORD('${n}');`),awaitf()({userId:s.id,mariadbUser:d,mariadbUserHost:l,sqlUserID:i.id}),r.json({success:!0})}catch(e){l()({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})}}s(29021);letw=(0,o.M)(t,"default"),q=(0,o.M)(t,"config"),x=newi.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/sql-users/update",pathname:"/api/sql-users/update",bundlePath:"",filename:""},userland:t})}};varr=require("../../../webpack-api-runtime.js");r.C(e);vars=e=>r(r.s=e),t=r.X(0,[5264],()=>s(46849));module.exports=t})();