PageSourceSearch

https://xterns.ai/assets/ResetPassword-CHQOHUNY.js

js xterns.ai collected 2026-10-05 13:23:20 UTC 5,699 bytes, 1 lines download raw bytes

1import{o as $,u as q,r as o,j as e,h as u,m as g,p as _,B as y,i as R,e as U,k as V,l as B,I as j,s as d,g as l}from"./index-DLd_kDlx.js";import{L as b}from"./label-D4-ENrYn.js";import{L as x}from"./Layout-B4HKaXoo.js";import{L as N}from"./loader-circle-D2miE2xB.js";const A=()=>{const[m]=$(),c=q(),[t,k]=o.useState(""),[w,v]=o.useState(""),[p,f]=o.useState(!1),[P,h]=o.useState(!1),[C,L]=o.useState(!0);o.useEffect(()=>{(async()=>{let r=m.get("access_token"),a=m.get("refresh_token");if(!r||!a){const s=new URLSearchParams(window.location.hash.substring(1));r=s.get("access_token")||r,a=s.get("refresh_token")||a}if(r&&a)try{const{data:s,error:i}=await d.auth.setSession({access_token:r,refresh_token:a});if(i)throw i;h(!0);const T=window.location.pathname;window.history.replaceState({},document.title,T)}catch(s){console.error("Invalid reset token:",s);const{data:i}=await d.auth.getSession();i!=null&&i.session?h(!0):(l.error("Invalid or expired reset link"),c("/login"))}else{const{data:s}=await d.auth.getSession();s!=null&&s.session?h(!0):(l.error("Invalid reset link"),c("/login"))}L(!1)})()},[m,c]);const S=n=>{const r=n.length>=8,a=/\d/.test(n),s=/[!@#$%^&*(),.?":{}|<>]/.test(n);return{isValid:r&&a&&s,requirements:{minLength:r,hasNumber:a,hasSymbol:s}}},I=async n=>{if(n.preventDefault(),t!==w){l.error("Passwords don't match");return}const r=S(t);if(!r.isValid){let a="Password must meet all requirements: ";const s=[];r.requirements.minLength||s.push("at least 8 characters"),r.requirements.hasNumber||s.push("include a number"),r.requirements.hasSymbol||s.push("include a symbol"),l.error(a+s.join(", "));return}f(!0);try{const{error:a}=await d.auth.updateUser({password:t});if(a)throw a;l.success("Your password has been reset successfully. Please log in with your new password.",{description:"Redirecting to login page..."}),await d.auth.signOut(),setTimeout(()=>{c("/login",{state:{message:"Your password has been reset successfully. Please log in with your new password."}})},2e3)}catch(a){console.error("Password reset error:",a),l.error("Failed to update password",{description:a.message||"Please try again."})}finally{f(!1)}};return C?e.jsx(x,{children:e.jsx("div",{className:"container max-w-md py-16 md:py-24",children:e.jsx(u,{className:"shadow-lg border-0 bg-white/95 backdrop-blur-sm",children:e.jsxs(g,{className:"p-12 text-center",children:[e.jsx(N,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-primary"}),e.jsx("p",{className:"text-gray-600",children:"Verifying reset link..."})]})})})}):P?e.jsx(x,{children:e.jsx("div",{className:"container max-w-md py-16 md:py-24",children:e.jsxs(u,{className:"shadow-lg border-0 bg-white/95 backdrop-blur-sm",children:[e.jsxs(R,{className:"text-center pb-6",children:[e.jsx("div",{className:"w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(U,{className:"h-6 w-6 text-green-600"})}),e.jsx(V,{className:"text-2xl font-bold text-gray-900",children:"Set New Password"}),e.jsx(B,{className:"text-gray-600",children:"Choose a strong password for your account"})]}),e.jsx(g,{children:e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"new-password",className:"text-sm font-medium text-gray-700",children:"New Password"}),e.jsx(j,{id:"new-password",type:"password",placeholder:"Enter your new password",value:t,onChange:n=>k(n.target.value),required:!0,minLength:8,className:"h-11"}),e.jsxs("div",{className:"text-xs text-gray-500 space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Password requirements:"}),e.jsxs("ul",{className:"space-y-1",children:[e.jsxs("li",{className:`flex items-center gap-2 ${t.length>=8?"text-green-600":"text-gray-400"}`,children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${t.length>=8?"bg-green-600":"bg-gray-300"}`}),"At least 8 characters"]}),e.jsxs("li",{className:`flex items-center gap-2 ${/\d/.test(t)?"text-green-600":"text-gray-400"}`,children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${/\d/.test(t)?"bg-green-600":"bg-gray-300"}`}),"Include a number"]}),e.jsxs("li",{className:`flex items-center gap-2 ${/[!@#$%^&*(),.?":{}|<>]/.test(t)?"text-green-600":"text-gray-400"}`,children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${/[!@#$%^&*(),.?":{}|<>]/.test(t)?"bg-green-600":"bg-gray-300"}`}),"Include a symbol (!@#$%^&*)"]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"confirm-new-password",className:"text-sm font-medium text-gray-700",children:"Confirm New Password"}),e.jsx(j,{id:"confirm-new-password",type:"password",placeholder:"Confirm your new password",value:w,onChange:n=>v(n.target.value),required:!0,minLength:8,className:"h-11"})]}),e.jsx(y,{type:"submit",className:"w-full h-11 bg-primary hover:bg-primary/90 text-white font-medium",disabled:p,children:p?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"mr-2 h-4 w-4 animate-spin"}),"Updating Password..."]}):"Update Password"})]})})]})})}):e.jsx(x,{children:e.jsx("div",{className:"container max-w-md py-16 md:py-24",children:e.jsx(u,{className:"shadow-lg border-red-200 bg-red-50/50",children:e.jsxs(g,{className:"p-12 text-center",children:[e.jsx("div",{className:"w-12 h-12 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(_,{className:"h-6 w-6 text-red-600"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Invalid Reset Link"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"This password reset link is invali
1d or has expired."}),e.jsx(y,{onClick:()=>c("/login"),className:"bg-primary hover:bg-primary/90",children:"Back to Login"})]})})})})};export{A 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.