"use strict";(()=>{var e={};e.id=9187,e.ids=[9187],e.modules={43499:e=>{e.exports=require("@moduletrace/datasquirel/functions/hashPassword")},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")},49915:(e,r,s)=>{s.r(r),s.d(r,{config:()=>_,default:()=>m,routeModule:()=>h});var t={};s.r(t),s.d(t,{default:()=>f});var a=s(89947),i=s(2706),n=s(96762),u=s(43499),l=s.n(u),o=s(6420),d=s.n(o),c=s(47670),p=s.n(c);async function f(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});if(!await d()(e,r,!0))return r.json({success:!1,msg:"Unauthorized"});let{payload:s,dbFullName:t,dbId:a}=e.body,i=await p()({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:t,tableName:"users",data:(()=>{let e=Object.keys(s),r={};return e.forEach(e=>{e?.match(/paradigm|priviledge|database_access|databases|confirm/)||(r[e]=s[e])}),r.password=l()({encryptionKey:process.env.DSQL_ENCRYPTION_PASSWORD||"",password:s.password}),r.email=s.email_address,r.image="/images/user-preset.png",r.image_thumbnail="/images/user-preset-thumbnail.png",delete r.email_address,r})()});r.json({success:!!i?.insertId,msg:"New User User Added",newUserId:i.insertId})}let m=(0,n.M)(t,"default"),_=(0,n.M)(t,"config"),h=new a.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/addDbUser",pathname:"/api/addDbUser",bundlePath:"",filename:""},userland:t})},6420:(e,r,s)=>{s(81630);let t=s(51348),a=s(72907),i=s(29021);async function n(e,r,s,n){if(!e.cookies?.datasquirelAuthKey?.match(/./))return null;let u=a(e.cookies.datasquirelAuthKey);if(!u)return null;let l=JSON.parse(u);if(!l.csrf_k||s&&!e.headers["x-csrf-auth"]?.match(RegExp(`${l.csrf_k}`)))return null;let o=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!o)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(s&&!i.existsSync(`${o}/${l.csrf_k}`))return null;if(0==l.verification_status&&!s){let e=await t(`SELECT verification_status FROM users WHERE id='${l.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}return l?.date&&Date.now()-l.date>6048e5?null:l}e.exports=n},72907:(e,r,s)=>{let{scryptSync:t,createDecipheriv:a}=s(55511),{Buffer:i}=s(79428);e.exports=e=>{let r=a("aes-192-cbc",t(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),i.alloc(16,0));try{let s=r.update(e,"hex","utf8");return s+=r.final("utf8")}catch(e){return null}}}};var r=require("../../webpack-api-runtime.js");r.C(e);var s=e=>r(r.s=e),t=r.X(0,[4050],()=>s(49915));module.exports=t})();