dsql-admin/dsql-app/.local_dist/server/pages/api/resetPassword.js
Benjamin Toby 7a06e83a46 Updates
2024-12-08 20:56:57 +01:00

1 line
2.5 KiB
JavaScript

"use strict";(()=>{var e={};e.id=9971,e.ids=[9971],e.modules={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")},29021:e=>{e.exports=require("fs")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},24127:(e,r,t)=>{t.r(r),t.d(r,{config:()=>P,default:()=>l,routeModule:()=>f});var s={};t.r(s),t.d(s,{default:()=>d});var n=t(89947),o=t(2706),i=t(96762),a=t(14533),u=t.n(a),c=t(51348),p=t.n(c);async function d(e,r){if("GET"!==e.method)return r.json({msg:"UNauthorized"});{let{email:t,password:s}=e.query,n=u()({encryptionKey:process.env.DSQL_ENCRYPTION_PASSWORD||"",password:String(s)}),o=await p()(`UPDATE users SET password='${n}' WHERE email='${t}'`);r.json({success:!!o?.affectedRows})}}let l=(0,i.M)(s,"default"),P=(0,i.M)(s,"config"),f=new n.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/resetPassword",pathname:"/api/resetPassword",bundlePath:"",filename:""},userland:s})},14533:(e,r,t)=>{let{createHmac:s}=t(55511);e.exports=function({password:e,encryptionKey:r}){let t=r||process.env.DSQL_ENCRYPTION_PASSWORD;if(!t?.match(/.{8,}/))throw Error("Encryption key is invalid");let n=s("sha512",t);return n.update(e),n.digest("base64")}},51348:(e,r,t)=>{let s=t(9973),n=t(21580),o=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:n()}});async function i(...e){try{let r=await o.query(...e);return await o.end(),JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=i},21580:(e,r,t)=>{let s=t(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let r=`${e}/ca-cert.pem`;if(!s.existsSync(r)){console.log(`${r} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},2706:(e,r)=>{var t;Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(t||(t={}))},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=24127);module.exports=t})();