dsql-admin/dsql-app/.local_dist/server/pages/api/changeDbUserPassword.js

1 line
4.2 KiB
JavaScript
Raw Normal View History

2025-01-14 15:27:08 +00:00
"use strict";(()=>{var e={};e.id=7963,e.ids=[7963],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")},9973:e=>{e.exports=require("serverless-mysql")},55511:e=>{e.exports=require("crypto")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,s){return s in r?r[s]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,s)):"function"==typeof r&&"default"===s?r:void 0}}})},94649:(e,r,s)=>{s.r(r),s.d(r,{config:()=>d,default:()=>S,routeModule:()=>p});var n={};s.r(n),s.d(n,{default:()=>u});var o=s(89947),t=s(2706),a=s(96762),i=s(48786),c=s(69842),_=s(83919);async function u(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});if(!await (0,c.A)(e,r,!0))return r.json({success:!1,msg:"Unauthorized"});let{userId:s,password:n,dbId:o}=e.body;try{let e=!!String(o).match(/^\d+$/),t=!!String(s).match(/^\d+$/),a=!!String(n).match(/ /);if(!e||!t)throw Error("Invalud Parameters!");if(a)throw Error("Invalid Password!");let c=await (0,i.A)("SELECT * FROM user_databases WHERE id = ?",[o]),u=c?.[0]?.db_full_name,S=(0,_.A)({encryptionKey:process.env.DSQL_ENCRYPTION_PASSWORD||"",password:n});await (0,i.A)(`UPDATE \`${u}\`.\`users\` SET password = ? WHERE id = ?`,[S,s]),r.json({success:!0,msg:"DB user Password Changed!"})}catch(e){r.json({success:!1,msg:e.message})}}let S=(0,a.M)(n,"default"),d=(0,a.M)(n,"config"),p=new o.PagesAPIRouteModule({definition:{kind:t.A.PAGES_API,page:"/api/changeDbUserPassword",pathname:"/api/changeDbUserPassword",bundlePath:"",filename:""},userland:n})},69842:(e,r,s)=>{s.d(r,{A:()=>t});var n=s(39908),o=s.n(n);async function t(e,r,s){let n=o()({req:e,level:s?"deep":void 0});return console.log(n),n.payload}},83919:(e,r,s)=>{s.d(r,{A:()=>t});var n=s(55511),o=s(32443);function t({password:e,encryptionKey:r}){let{key:s}=(0,o.A)({encryptionKey:r});if(!s?.match(/.{8,}/))throw Error("Encryption key is invalid");let t=(0,n.createHmac)("sha512",s);return t.update(e),t.digest("base64")}},48786:(e,r,s)=>{s.d(r,{A:()=>o});var n=s(7447);async function o(...e){let r=(0,n.A)();try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let s=await r.query(...e);return JSON.parse(JSON.stringify(s))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},7447:(e,r,s)=>{s.d(r,{A:()=>t});var n=s(9973),o=s.n(n);function t(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},32443:(e,r,s)=>{s.d(r,{A:()=>n});function n(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?function(e,r){try{let r=Number(e);if("number"!=typeof r||isNaN(r))return 0;return Math.round(r)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return s}});var s=function(e){return e.PAG