PageSourceSearch

https://morvo.co.uk/assets/ResetPassword-dBzOr1ql.js

js morvo.co.uk collected 2026-09-24 09:52:10 UTC 5,772 bytes, 1 lines download raw bytes

1import{W as K,V as Q,r,j as e,N as x,h as p,F as g,L as w,a9 as T,B as C,q as L,I as q,U as c}from"./index-CRQcHE7J.js";import{C as j}from"./card-DWLMxT6t.js";import{o as X,s as _}from"./types-By9teAtI.js";const Z=X({password:_().min(8,"Password must be at least 8 characters"),confirmPassword:_()}).refine(m=>m.password===m.confirmPassword,{message:"Passwords don't match",path:["confirmPassword"]}),re=()=>{const m=K(),{toast:v}=Q(),[f,I]=r.useState(""),[N,F]=r.useState(""),[y,b]=r.useState(!1),[U,l]=r.useState(!1),[V,t]=r.useState(!0),[h,P]=r.useState({}),[A,B]=r.useState(null);r.useEffect(()=>{(async()=>{console.log("Reset password hash:",window.location.hash);const s=new URLSearchParams(window.location.hash.substring(1)),d=s.get("error"),a=s.get("error_description");if(d){console.error("Password reset error from redirect:",d,a),B(a?.includes("expired")?"This password reset link has expired. Please request a new one from the login page.":a||"This password reset link is invalid. Please request a new one."),t(!1),window.history.replaceState(null,"",window.location.pathname);return}const n=s.get("access_token"),M=s.get("refresh_token"),z=s.get("type"),u=new URLSearchParams(window.location.search),O=u.get("access_token"),Y=u.get("refresh_token"),W=u.get("type"),S=u.get("code"),k=n||O,E=M||Y,R=z||W;if(S){const{error:i}=await c.auth.exchangeCodeForSession(S);i||l(!0),t(!1),window.history.replaceState(null,"",window.location.pathname);return}if((R==="recovery"||R==="magiclink")&&k&&E){const{error:i}=await c.auth.setSession({access_token:k,refresh_token:E});i||l(!0),t(!1),window.history.replaceState(null,"",window.location.pathname);return}const{data:{subscription:G}}=c.auth.onAuthStateChange((i,J)=>{(i==="PASSWORD_RECOVERY"||i==="SIGNED_IN"&&J)&&(l(!0),t(!1))}),{data:{session:H}}=await c.auth.getSession();return H&&l(!0),t(!1),()=>G.unsubscribe()})()},[]);const D=async o=>{o.preventDefault(),P({});const s=Z.safeParse({password:f,confirmPassword:N});if(!s.success){const a={};s.error.errors.forEach(n=>{n.path[0]==="password"&&(a.password=n.message),n.path[0]==="confirmPassword"&&(a.confirmPassword=n.message)}),P(a);return}b(!0);const{error:d}=await c.auth.updateUser({password:f});if(d){v({title:"Error",description:d.message,variant:"destructive"}),b(!1);return}await c.auth.signOut(),v({title:"Password updated",description:"Your password has been reset successfully. Please log in with your new password."}),m("/login")};return V?e.jsxs("div",{className:"min-h-screen",children:[e.jsx(x,{}),e.jsxs("div",{className:"min-h-screen flex items-center justify-center relative p-4 pt-24",children:[e.jsx("img",{src:p,alt:"",className:"absolute inset-0 w-full h-full object-cover","aria-hidden":"true"}),e.jsx("div",{className:"relative z-10 w-full flex items-center justify-center",children:e.jsx(j,{className:"w-full max-w-md p-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Verifying reset link..."})})})]}),e.jsx(g,{})]}):U?e.jsxs("div",{className:"min-h-screen",children:[e.jsx(x,{}),e.jsxs("div",{className:"min-h-screen flex items-center justify-center relative p-4 pt-24",children:[e.jsx("img",{src:p,alt:"",className:"absolute inset-0 w-full h-full object-cover","aria-hidden":"true"}),e.jsx("div",{className:"relative z-10 w-full flex items-center justify-center",children:e.jsxs(j,{className:"w-full max-w-md p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx(w,{to:"/",className:"inline-block mb-6",children:e.jsx("img",{src:T,alt:"Morvo",className:"h-10 mx-auto"})}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Reset Your Password"}),e.jsx("p",{className:"text-muted-foreground",children:"Enter your new password below"})]}),e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(L,{htmlFor:"password",children:"New Password"}),e.jsx(q,{id:"password",type:"password",value:f,onChange:o=>I(o.target.value),placeholder:"Enter new password",className:"mt-1",maxLength:128,required:!0}),h.password&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:h.password})]}),e.jsxs("div",{children:[e.jsx(L,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(q,{id:"confirmPassword",type:"password",value:N,onChange:o=>F(o.target.value),placeholder:"Confirm new password",className:"mt-1",maxLength:128,required:!0}),h.confirmPassword&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:h.confirmPassword})]}),e.jsx(C,{type:"submit",disabled:y,className:"w-full bg-gradient-primary",children:y?"Updating Password...":"Reset Password"})]}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground mt-6",children:["Remember your password?"," ",e.jsx(w,{to:"/login",className:"text-primary hover:underline",children:"Sign in"})]})]})})]}),e.jsx(g,{})]}):e.jsxs("div",{className:"min-h-screen",children:[e.jsx(x,{}),e.jsxs("div",{className:"min-h-screen flex items-center justify-center relative p-4 pt-24",children:[e.jsx("img",{src:p,alt:"",className:"absolute inset-0 w-full h-full object-cover","aria-hidden":"true"}),e.jsx("div",{className:"relative z-10 w-full flex items-center justify-center",children:e.jsxs(j,{className:"w-full max-w-md p-8 text-center",children:[e.jsx("div",{className:"mb-6",children:e.jsx(w,{to:"/",className:"inline-block",children:e.jsx("img",{src:T,alt:"Morvo",className:"h-10 mx-auto"})})}),e.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Invalid or Expired Link"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:A||"This password reset link is invali
1d or has expired. Please request a new one."}),e.jsx(w,{to:"/login",children:e.jsx(C,{className:"w-full bg-gradient-primary",children:"Back to Login"})})]})})]}),e.jsx(g,{})]})};export{re 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.