PageSourceSearch

https://sariverwalk.com/assets/reset-password-CwhzYaVi.js

js sariverwalk.com collected 2026-10-10 02:16:58 UTC 7,862 bytes, 6 lines download raw bytes

1import{c as Y,w as A,d as $,r as t,e as G,g as Q,u as W,f as H,O as K,j as e,N,C as y,z as v,T as _,D as u,G as p,a as P,L as c,B as r,Q as k,F as b,I as C,V as L,W as S,y as E,R as J}from"./index-CHCCGYt6.js";import{u as X,F as Z,a as F,b as R,c as T,d as I,e as z,t as ee,z as j}from"./form-CFU0fwwl.js";import{C as se}from"./circle-check-big-COJVkrsF.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ae=Y("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),te=j.object({newPassword:j.string().min(6,"Password must be at least 6 characters"),confirmPassword:j.string().min(6,"Please confirm your password")}).refine(a=>a.newPassword===a.confirmPassword,{message:"Passwords don't match",path:["confirmPassword"]});function de(){const{user:a,isLoading:d}=A(),[,n]=$(),[i,q]=t.useState(""),[l,V]=t.useState(!1),[m,B]=t.useState(!1),[h,O]=t.useState(!1),{toast:f}=G();t.useEffect(()=>{const w=new URLSearchParams(window.location.search).get("token");w?q(w):n("/forgot-password")},[n]),t.useEffect(()=>{const s=Q("auth",{path:"/reset-password",title:`Create New Password - ${E.siteName}`,description:`Create a new password for your ${E.siteName} account.`});W(s)},[]);const o=X({resolver:ee(te),defaultValues:{newPassword:"",confirmPassword:""}});t.useEffect(()=>{!d&&a&&(a.role==="admin"?n("/admin"):a.role==="directory_user"?n("/dashboard"):n("/"))},[d,a,n]);const{data:D,isLoading:g,error:M}=H({queryKey:["validate-reset-token",i],queryFn:async()=>{if(!i)return null;const s=await fetch(`/api/auth/reset-password/validate?token=${encodeURIComponent(i)}`,{method:"GET",credentials:"include"});if(!s.ok)throw new Error("Invalid or expired token");return await s.json()},enabled:!!i,retry:!1}),x=K({mutationFn:async s=>await(await J("POST","/api/auth/reset-password",{token:i,newPassword:s.newPassword})).json(),onSuccess:()=>{O(!0),f({title:"Password reset successful",description:"Your password has been updated. You can now log in with your new password."})},onError:s=>{f({title:"Password reset failed",description:s.message||"Please try again or request a new reset link.",variant:"destructive"})}}),U=s=>{x.mutate(s)};return!d&&a?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-gray-600",children:"Redirecting..."})})}):d||g?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-gray-600",children:g?"Validating reset link...":"Loading..."})]})}):M||!D?e.jsxs("div",{children:[e.jsx(N,{}),e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs(y,{"data-testid":"card-invalid-token",children:[e.jsxs(v,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(_,{className:"w-16 h-16 text-red-600"})}),e.jsx(u,{className:"text-2xl text-red-800","data-testid":"heading-invalid-token",children:"Invalid Reset Link"}),e.jsx(p,{"data-testid":"text-invalid-token-description",children:"This password reset link is invalid or has expired."})]}),e.jsxs(P,{className:"text-center space-y-4",children:[e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-sm text-red-800",children:[e.jsx("p",{className:"font-medium",children:"Why might this happen?"}),e.jsxs("ul",{className:"mt-1 space-y-1 text-red-700",children:[e.jsx("li",{children:"• The link has expired (links expire after 15 minutes)"}),e.jsx("li",{children:"• The link has already been used"}),e.jsx("li",{children:"• The link was copied incorrectly"})]})]}),e.jsx(c,{href:"/forgot-password","data-testid":"link-request-new-reset",children:e.jsx(r,{className:"w-full",children:"Request New Reset Link"})}),e.jsx(c,{href:"/auth","data-testid":"link-back-to-login-error",children:e.jsxs(r,{variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-900",children:[e.jsx(k,{className:"w-4 h-4 mr-2"}),"Back to Login"]})})]})]})})}),e.jsx(b,{})]}):e.jsxs("div",{children:[e.jsx(N,{}),e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs(y,{"data-testid":"card-reset-password",children:[e.jsx(v,{className:"text-center",children:h?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(se,{className:"w-16 h-16 text-green-600"})}),e.jsx(u,{className:"text-2xl text-green-800","data-testid":"heading-success",children:"Password Reset Successful"}),e.jsx(p,{"data-testid":"text-success-description",children:"Your password has been updated successfully"})]}):e.jsxs(e.Fragment,{children:[e.jsx(u,{className:"text-2xl","data-testid":"heading-reset-password",children:"Create New Password"}),e.jsx(p,{"data-testid":"text-reset-password-description",children:"Enter your new password below"})]})}),e.jsxs(P,{children:[h?e.jsxs("div",{className:"text-center space-y-4","data-testid":"reset-success-content",children:[e.jsx("p",{className:"text-gray-600","data-testid":"text-reset-success",children:"You can now log in to your account with your new password."}),e.jsx(c,{href:"/auth","data-testid":"link-login-now",children:e.jsx(r,{className:"w-full",children:"Log In Now"})})]}):e.jsx(Z,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(U),className:"space-y-4","data-testid":"form-reset-password",children:[e.jsx(F,{control:o.control,name:"newPassword",render:({field:s})=>e.jsxs(R,{children:[e.jsx(T,{"data-testid":"label-new-password",children:"New Password"}),e.jsx(I,{children:e.jsxs("div",{className:"relative",children:[e.jsx(C,{type:l?"text":"password",placeholder:"Enter new password (min. 6 characters)",...s,"data-testid":"input-new-password"}),e.jsx(r,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 h-auto p-1",onClick:()=>V(!l),"data-testid":"button-toggle-password",children:l?e.jsx(L,{className:"w-4 h-4"}):e.jsx(S,{className:"w-4 h-4"})})]})}),e.jsx(z,{"data-testid":"error-new-password"})]})}),e.jsx(F,{control:o.control,name:"confirmPassword",render:({field:s})=>e.jsxs(R,{children:[e.jsx(T,{"data-testid":"label-confirm-password",children:"Confirm New Password"}),e.jsx(I,{children:e.jsxs("div",{className:"relative",children:[e.jsx(C,{type:m?"text":"password",placeholder:"Confirm new password",...s,"data-testid":"input-confirm-password"}),e.jsx(r,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 h-auto p-1",onClick:()=>B(!m),"data-testid":"button-toggle-confirm-password",children:m?e.jsx(L,{className:"w-4 h-4"}):e.jsx(S,{className:"w-4 h-4"})})]})}),e.jsx(z,{"data-testid":"error-confirm-password"})]})}),e.jsx(r,{type:"submit",className:"w-full",disabled:x.isPending,"data-testid":"button-reset-password",children:x.isPending?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin w-4 h-4 border-2 border-white border-t-transparent roun
6ded-full"}),"Updating Password..."]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Update Password"]})})]})}),!h&&e.jsx("div",{className:"mt-6 text-center",children:e.jsx(c,{href:"/auth","data-testid":"link-back-to-login",children:e.jsxs(r,{variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-900",children:[e.jsx(k,{className:"w-4 h-4 mr-2"}),"Back to Login"]})})})]})]})})}),e.jsx(b,{})]})}export{de as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.