PageSourceSearch

https://willowcommerce.com/assets/ResetPassword-DRyu4TFT.js

js willowcommerce.com collected 2026-10-04 03:01:12 UTC 4,967 bytes, 1 lines download raw bytes

1import{b as H,r,w as l,j as e,C as J,d as K,e as M,f as Q,m as X,l as U,B as j,L as I,I as q,E as Z,n as $,v as p}from"./index-Cz3wH2jj.js";import{W as ee}from"./WillowcommerceLogo-CDuBtfMK.js";import"./willowcommerce-logo-BmH0M6Ez.js";function ae(){const y=H(),[d,D]=r.useState(""),[N,F]=r.useState(""),[u,W]=r.useState(!1),[S,b]=r.useState(!1),[v,B]=r.useState(!1),[O,k]=r.useState(!1),[P,C]=r.useState(""),[x,z]=r.useState(""),[g,A]=r.useState("");r.useEffect(()=>{let a=!1,o;const m=t=>{if(a)return;z(t.user.email||"");const s=t.user.user_metadata,n=(s==null?void 0:s.full_name)||[s==null?void 0:s.first_name,s==null?void 0:s.last_name].filter(Boolean).join(" ")||(s==null?void 0:s.name)||"";A(n),C(""),k(!0)},h=(t="This reset link is invalid or expired. Please request a new password reset link.")=>{a||(C(t),k(!0))},{data:{subscription:Y}}=l.auth.onAuthStateChange((t,s)=>{if(t==="PASSWORD_RECOVERY"||t==="SIGNED_IN"){if(s!=null&&s.user){m(s);return}h()}}),G=async()=>{var t,s;try{const n=new URLSearchParams(window.location.hash.replace(/^#/,"")),f=new URLSearchParams(window.location.search),E=n.get("error_description")||f.get("error_description");if(E)throw new Error(E.replace(/\+/g," "));const L=n.get("access_token")||f.get("access_token"),_=n.get("refresh_token")||f.get("refresh_token"),R=f.get("code");if(L&&_){const{data:i,error:c}=await l.auth.setSession({access_token:L,refresh_token:_});if(c)throw c;if((t=i.session)!=null&&t.user){window.history.replaceState(null,document.title,window.location.pathname),m(i.session);return}}if(R){const{data:i,error:c}=await l.auth.exchangeCodeForSession(R);if(c)throw c;if((s=i.session)!=null&&s.user){window.history.replaceState(null,document.title,window.location.pathname),m(i.session);return}}const{data:{session:w},error:T}=await l.auth.getSession();if(T)throw T;if(w!=null&&w.user){m(w);return}h()}catch(n){h((n==null?void 0:n.message)||void 0)}};return o=setTimeout(()=>{h("We could not verify this reset link. Please request a new password reset link.")},1e4),G().finally(()=>clearTimeout(o)),()=>{a=!0,clearTimeout(o),Y.unsubscribe()}},[]);const V=async a=>{if(a.preventDefault(),d!==N){p.error("Passwords do not match");return}if(d.length<6){p.error("Password must be at least 6 characters");return}b(!0);try{const{error:o}=await l.auth.updateUser({password:d});if(o)throw o;B(!0),p.success("Password updated successfully!"),setTimeout(()=>y("/brand/login"),3e3)}catch(o){p.error(o.message||"Failed to reset password")}finally{b(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-background to-muted p-4",children:e.jsxs(J,{className:"w-full max-w-md",children:[e.jsxs(K,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(ee,{})}),e.jsx(M,{className:"text-base",children:v?"Password updated":"Set your new password"})]}),e.jsx(Q,{children:v?e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(X,{className:"h-12 w-12 text-emerald-500 mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your password has been updated. Redirecting to sign in..."})]}):O?P?e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:P}),e.jsx(j,{type:"button",className:"w-full",onClick:()=>y("/forgot-password"),children:"Request New Link"})]}):e.jsxs("form",{onSubmit:V,className:"space-y-4",children:[(x||g)&&e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 mb-2",children:[g&&e.jsx("p",{className:"text-sm font-medium",children:g}),x&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Setting password for"}),e.jsx("p",{className:"text-sm font-medium",children:x})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"password",children:"New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(q,{id:"password",type:u?"text":"password",value:d,onChange:a=>D(a.target.value),placeholder:"Enter new password",required:!0,minLength:6}),e.jsx(j,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>W(!u),children:u?e.jsx(Z,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(q,{id:"confirmPassword",type:u?"text":"password",value:N,onChange:a=>F(a.target.value),placeholder:"Confirm new password",required:!0,minLength:6})]}),e.jsxs(j,{type:"submit",className:"w-full",size:"lg",disabled:S,children:[S&&e.jsx(U,{className:"mr-2 h-4 w-4 animate-spin"}),"Update Password"]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx(U,{className:"h-8 w-8 animate-spin text-primary"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Verifying your link..."})]})})]})})}export{ae 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.