"use strict";(()=>{var e={};e.id=814,e.ids=[814],e.modules={11185:e=>{e.exports=require("mongoose")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},76162:e=>{e.exports=require("stream")},21764:e=>{e.exports=require("util")},68700:(e,r,s)=>{s.r(r),s.d(r,{originalPathname:()=>f,patchFetch:()=>v,requestAsyncStorage:()=>m,routeModule:()=>h,serverHooks:()=>w,staticGenerationAsyncStorage:()=>g});var t={};s.r(t),s.d(t,{POST:()=>l});var n=s(49303),a=s(88716),o=s(60670),i=s(87070),u=s(98691),p=s(14184),c=s(58480),d=s(95456);async function l(e){try{let{valid:r,error:s}=(0,d.Gl)(e);if(!r)return i.NextResponse.json({success:!1,error:s},{status:401});await (0,p.Z)();let{currentPassword:t,newPassword:n}=await e.json();if(!t||!n)return i.NextResponse.json({success:!1,error:"Current and new passwords are required"},{status:400});if(n.length<4)return i.NextResponse.json({success:!1,error:"New password must be at least 4 characters"},{status:400});let a=await c.Z.findOne();if(!a)return i.NextResponse.json({success:!1,error:"App settings not found"},{status:404});if(!await u.ZP.compare(t,a.passwordHash))return i.NextResponse.json({success:!1,error:"Current password is incorrect"},{status:401});return a.passwordHash=await u.ZP.hash(n,12),await a.save(),i.NextResponse.json({success:!0,data:{message:"Password changed successfully"}})}catch(e){return i.NextResponse.json({success:!1,error:e instanceof Error?e.message:"Failed to change password"},{status:500})}}let h=new n.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/auth/change-password/route",pathname:"/api/auth/change-password",filename:"route",bundlePath:"app/api/auth/change-password/route"},resolvedPagePath:"E:\\WEB Project\\My Plan\\src\\app\\api\\auth\\change-password\\route.ts",nextConfigOutput:"",userland:t}),{requestAsyncStorage:m,staticGenerationAsyncStorage:g,serverHooks:w}=h,f="/api/auth/change-password/route";function v(){return(0,o.patchFetch)({serverHooks:w,staticGenerationAsyncStorage:g})}},95456:(e,r,s)=>{s.d(r,{Gl:()=>i,fT:()=>o});var t=s(41482),n=s.n(t);let a=process.env.JWT_SECRET||"my-plan-app-secret-key-change-this";function o(e,r){return n().sign(e,r||a,{expiresIn:"30d"})}function i(e){var r;let s=(r=e.headers.get("Authorization"))&&r.startsWith("Bearer ")?r.slice(7):null;return s?!function(e,r){try{return n().verify(e,r||a)}catch{return null}}(s,process.env.JWT_SECRET||a)?{valid:!1,error:"Invalid or expired token"}:{valid:!0}:{valid:!1,error:"No token provided"}}},14184:(e,r,s)=>{s.d(r,{Z:()=>i});var t=s(11185),n=s.n(t);let a=process.env.MONGODB_URI;if(!a)throw Error("Please define the MONGODB_URI environment variable inside .env.local");let o=global.mongoose;o||(o=global.mongoose={conn:null,promise:null});let i=async function(){if(o.conn)return o.conn;o.promise||(o.promise=n().connect(a,{bufferCommands:!1}));try{o.conn=await o.promise}catch(e){throw o.promise=null,e}return o.conn}},58480:(e,r,s)=>{s.d(r,{Z:()=>o});var t=s(11185),n=s.n(t);let a=new t.Schema({passwordHash:{type:String,required:!0},jwtSecret:{type:String,required:!0}},{timestamps:!0}),o=n().models.AppSettings||n().model("AppSettings",a)}};var r=require("../../../../webpack-runtime.js");r.C(e);var s=e=>r(r.s=e),t=r.X(0,[948,972,843,482,691],()=>s(68700));module.exports=t})();