"use strict";(()=>{vare={};e.id=3812,e.ids=[3812],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},21572:e=>{e.exports=require("nodemailer")},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")},70955:(e,a,s)=>{s.r(a),s.d(a,{config:()=>_,default:()=>p,routeModule:()=>v});vart={};s.r(t),s.d(t,{default:()=>m});varr=s(89947),i=s(2706),n=s(96762),d=s(96052),l=s(69842),u=s(98e3),o=s(48786),c=s(83919);asyncfunctionm(e,a){if("POST"!==e.method)returna.json({msg:"Failed!"});lets=await(0,l.A)(e,a,!0);if(!s)returna.json({success:!1,msg:"Unauthorized"});lett=e.body,r=t.paradigm;if(r?.match(/database/)){lete=await(0,u.A)({dbFullName:"datasquirel",tableName:"user_users",data:(()=>{lete=Object.keys(t),a={};returne.forEach(e=>{e?.match(/paradigm|priviledge|database_access|databases|confirm/)||(a[e]=t[e])}),a.user_id=s.id,a.password=(0,c.A)({encryptionKey:process.env.DSQL_ENCRYPTION_PASSWORD||"",password:t.password}),a.user_type="database",a.email=t.email_address,a.image="/images/user-preset.png",a.image_thumbnail="/images/user-preset-thumbnail.png",deletea.email_address,a})()});a.json({success:!!e?.insertId,msg:"New User User Added",newUserId:e.insertId})}else{if(s?.email===t.email_address)returna.json({success:!1,msg:"Can't Invite yourself"});lete=await(0,o.A)("SELECT * FROM invitations WHERE invited_user_email=? AND inviting_user_id=?",[t.email_address,s.id]);if(e&&e[0])returna.json({success:!1,msg:"User Already Invited"});await(0,u.A)({dbFullName:"datasquirel",tableName:"invitations",data:{inviting_user_id:s.id,invited_user_email:t.email_address,database_access:t.database_access,priviledge:t.priviledge,db_tables_data:t.db_tables}});letr=await(0,d.A)({to:t.email_address,subject:`${s.first_name}${s.last_name} Invited you`,text:`${s.first_name}${s.last_name} has invited you to manage a datasquirel account`,html:`