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

1 line
2.0 KiB
JavaScript
Raw Normal View History

2025-01-13 08:00:21 +00:00
"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")},55511:e=>{e.exports=require("crypto")},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}}})},23297:(e,r,t)=>{t.r(r),t.d(r,{config:()=>P,default:()=>c,routeModule:()=>f});var n={};t.r(n),t.d(n,{default:()=>d});var o=t(89947),i=t(2706),a=t(96762),s=t(83919),u=t(48786);async function d(e,r){if("GET"!==e.method)return r.json({msg:"UNauthorized"});{let{email:t,password:n}=e.query,o=(0,s.A)({encryptionKey:process.env.DSQL_ENCRYPTION_PASSWORD||"",password:String(n)}),i=await (0,u.A)(`UPDATE users SET password='${o}' WHERE email='${t}'`);r.json({success:!!i?.affectedRows})}}let c=(0,a.M)(n,"default"),P=(0,a.M)(n,"config"),f=new o.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/resetPassword",pathname:"/api/resetPassword",bundlePath:"",filename:""},userland:n})},83919:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(55511);function o({password:e,encryptionKey:r}){let t=r||process.env.DSQL_ENCRYPTION_PASSWORD;if(!t?.match(/.{8,}/))throw Error("Encryption key is invalid");let o=(0,n.createHmac)("sha512",t);return o.update(e),o.digest("base64")}},48786:(e,r,t)=>{t.d(r,{A:()=>n});async function n(...e){let r=global.DSQL_DB_CONN;try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let t=await r.query(...e);return JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}});var t=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=23297);module.exports=t})();