dsql-admin/dsql-app/.local_dist/server/pages/api/addDbUser.js
Benjamin Toby 81cf010cb5 Updates
2025-01-14 16:27:08 +01:00

1 line
2.0 KiB
JavaScript

"use strict";(()=>{var e={};e.id=9187,e.ids=[9187],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")},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")},3931:(e,r,s)=>{s.r(r),s.d(r,{config:()=>c,default:()=>p,routeModule:()=>m});var a={};s.r(a),s.d(a,{default:()=>l});var t=s(89947),i=s(2706),d=s(96762),n=s(83919),u=s(69842),o=s(98e3);async function l(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});if(!await (0,u.A)(e,r,!0))return r.json({success:!1,msg:"Unauthorized"});let{payload:s,dbFullName:a,dbId:t}=e.body,i=await (0,o.A)({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:a,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=(0,n.A)({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 p=(0,d.M)(a,"default"),c=(0,d.M)(a,"config"),m=new t.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/addDbUser",pathname:"/api/addDbUser",bundlePath:"",filename:""},userland:a})},69842:(e,r,s)=>{s.d(r,{A:()=>i});var a=s(39908),t=s.n(a);async function i(e,r,s){let a=t()({req:e,level:s?"deep":void 0});return console.log(a),a.payload}},83919:(e,r,s)=>{s.d(r,{A:()=>i});var a=s(55511),t=s(32443);function i({password:e,encryptionKey:r}){let{key:s}=(0,t.A)({encryptionKey:r});if(!s?.match(/.{8,}/))throw Error("Encryption key is invalid");let i=(0,a.createHmac)("sha512",s);return i.update(e),i.digest("base64")}}};var r=require("../../webpack-api-runtime.js");r.C(e);var s=e=>r(r.s=e),a=r.X(0,[1251],()=>s(3931));module.exports=a})();