1 line
3.6 KiB
JavaScript
1 line
3.6 KiB
JavaScript
|
"use strict";(()=>{var e={};e.id=294,e.ids=[294],e.modules={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")},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")},98397:(e,r,s)=>{s.r(r),s.d(r,{config:()=>S,default:()=>E,routeModule:()=>m});var t={};s.r(t),s.d(t,{default:()=>f});var a=s(89947),i=s(2706),l=s(96762),n=s(51348),o=s.n(n),u=s(6420),d=s.n(u),c=s(47670),_=s.n(c);s(29021),s(33873);let{execSync:p}=s(79646);async function f(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let s=await d()(e,r,!0);if(!s)return r.json({success:!1,msg:"Unauthorized"});let{userObject:t,database_access:a,user_priviledge:i,db_tables:l,inv_user_id:n}=e.body,u=await o()("UPDATE user_users SET database_access = ? ,user_priviledge = ? WHERE user_id = ? AND email = ?",[a,i,s.id,t.email]),c=l.split("|");await o()(`DELETE FROM delegated_user_tables WHERE root_user_id='${s.id}' AND delegated_user_id='${n}'`);for(let e=0;e<c.length;e++){let[r,t]=c[e].split("-");await _()({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:n,root_user_id:s.id,database:r,table:t,priviledge:i}})}r.json({success:!!u?.affectedRows})}let E=(0,l.M)(t,"default"),S=(0,l.M)(t,"config"),m=new a.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/updateAdminUserAccess",pathname:"/api/updateAdminUserAccess",bundlePath:"",filename:""},userland:t})},6420:(e,r,s)=>{s(81630);let t=s(51348),a=s(72835),i=s(29021),l=s(31341);async function n(e,r,s,n){let{keyCookieName:o,csrfCookieName:u}=l();if(!e.cookies?.[o]?.match(/./))return null;let d=a({encryptedString:e.cookies[o]});if(!d)return null;let c=JSON.parse(d);if(!c.csrf_k||s&&!e.headers["x-csrf-auth"]?.match(RegExp(`${c.csrf_k}`)))return null;let _=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!_)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(s&&!i.existsSync(`${_}/${c.csrf_k}`))return null;if(0==c.verification_status&&!s){let e=await t(`SELECT verification_status FROM users WHERE id='${c.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}return c?.date&&Date.now()-c.date>6048e5?null:c}e.exports=n},31341:e=>{e.exports=function(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",t=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",a=r;e?.userId&&(a+=`user_${e.userId}_`),e?.database&&(a+=`${e.database}_`),a+=s;let i=r;return e?.userId&&(i+=`user_${e.userId}_`),e?.database&&(i+=`${e.database}_`),{keyCookieName:a,csrfCookieName:i+=t}}},72835:(e,r,s)=>{let{scryptSync:t,createDecipheriv:a}=s(55511),{Buffer:i}=s(79428);e.exports=({encryptedString:e,encryptionKey:r,encryptionSalt:s})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let l=r||process.env.DSQL_ENCRYPTION_PASSWORD,n=s||process.env.DSQL_ENCRYPTION_SALT,o=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!l?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!n?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let u=a("aes-192-cbc",t(l,n,o),i.alloc(16,0));try{let r=u.update(e,"hex","utf8");return r+=u.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}}};var r=require("../../webpack-api-runtime.js");r.C(e);var s=e=>r(r.s=e),t=r.X(0,[4050],()=>s(98397));module.exports=t})();
|