PageSourceSearch

https://floraflor.lovable.app/assets/ResetPassword-CFJqOzDB.js

js floraflor.lovable.app collected 2026-10-03 03:31:52 UTC 5,900 bytes, 1 lines download raw bytes

1import{f as z,o as F,r as n,j as e,P as p,B as d,C as V,c as I,d as A,e as U,a as D,s as m,J as a}from"./index-RxDZGo8S.js";import{I as y}from"./input-CS9s6izM.js";import{L as N}from"./label-Fqe9mk9Y.js";import{P as O,v as q}from"./passwordValidation-BvWPhTZF.js";import{E as b}from"./eye-off-B-zBr9_n.js";import{E as C}from"./eye-CB4j9jLn.js";const G=()=>{const r=z(),[u]=F(),[h,E]=n.useState(""),[g,P]=n.useState(""),[x,S]=n.useState(!1),[f,k]=n.useState(!1),[j,v]=n.useState(!1),[L,R]=n.useState(!0),[_,w]=n.useState(!1);n.useEffect(()=>{(async()=>{try{console.log("Starting password reset setup");const t=u.get("access_token"),i=u.get("refresh_token"),l=u.get("type");if(console.log("URL params:",{hasAccessToken:!!t,hasRefreshToken:!!i,type:l}),l==="recovery"&&t&&i){console.log("Setting session with recovery tokens");const{data:s,error:c}=await m.auth.setSession({access_token:t,refresh_token:i});if(c){console.error("Error setting session:",c),a.error("El enlace de restablecimiento ha expirado o no es válido"),r("/auth");return}s.session?(console.log("Session established successfully"),w(!0)):(console.error("No session after setting tokens"),a.error("No se pudo establecer la sesión"),r("/auth"))}else{console.log("No recovery tokens found, checking existing session");const{data:{session:s},error:c}=await m.auth.getSession();if(c){console.error("Error getting session:",c),a.error("Error al verificar la sesión"),r("/auth");return}if(!s){console.log("No valid session found"),a.error("El enlace de restablecimiento ha expirado. Por favor, solicita un nuevo enlace."),r("/auth");return}console.log("Valid session found"),w(!0)}}catch(t){console.error("Error in password reset setup:",t),a.error("Error al procesar el enlace de restablecimiento"),r("/auth")}finally{R(!1)}})()},[r,u]);const T=async o=>{var i,l;if(o.preventDefault(),h!==g){a.error("Las contraseñas no coinciden");return}const t=q(h);if(!t.valid){a.error(t.message);return}v(!0);try{console.log("Updating password");const{error:s}=await m.auth.updateUser({password:h});if(s)throw console.error("Error updating password:",s),s;console.log("Password updated successfully"),a.success("Contraseña actualizada exitosamente"),await m.auth.signOut(),r("/auth")}catch(s){console.error("Error updating password:",s),(i=s.message)!=null&&i.includes("session_not_found")?(a.error("La sesión ha expirado. Por favor, solicita un nuevo enlace de restablecimiento."),r("/auth")):(l=s.message)!=null&&l.includes("same_password")?a.error("La nueva contraseña debe ser diferente a la anterior"):a.error("Error al actualizar la contraseña: "+(s.message||"Error desconocido"))}finally{v(!1)}};return L?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-green-50 to-blue-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(p,{className:"mx-auto h-12 w-12 text-green-600 animate-pulse"}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Procesando enlace..."}),e.jsx("p",{className:"text-gray-600",children:"Verificando el enlace de restablecimiento"})]})}):_?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-green-50 to-blue-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md 
1space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(p,{className:"mx-auto h-12 w-12 text-green-600"}),e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"FloraFlor"}),e.jsx("p",{className:"text-gray-600",children:"Restablecer Contraseña"})]}),e.jsxs(V,{children:[e.jsxs(I,{children:[e.jsx(A,{children:"Nueva Contraseña"}),e.jsx(U,{children:"Ingresa tu nueva contraseña para acceder al sistema"})]}),e.jsx(D,{children:e.jsxs("form",{onSubmit:T,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(N,{htmlFor:"password",children:"Nueva Contraseña"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{id:"password",type:x?"text":"password",value:h,onChange:o=>E(o.target.value),placeholder:"••••••••",required:!0,minLength:8}),e.jsx(d,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0",onClick:()=>S(!x),children:x?e.jsx(b,{className:"h-4 w-4"}):e.jsx(C,{className:"h-4 w-4"})})]}),e.jsx("ul",{className:"text-xs text-muted-foreground mt-1 space-y-0.5",children:O.map((o,t)=>e.jsxs("li",{children:["• ",o]},t))})]}),e.jsxs("div",{children:[e.jsx(N,{htmlFor:"confirmPassword",children:"Confirmar Contraseña"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{id:"confirmPassword",type:f?"text":"password",value:g,onChange:o=>P(o.target.value),placeholder:"••••••••",required:!0,minLength:6}),e.jsx(d,{type:"button",variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 transform -translate-y-1/2 h-7 w-7 p-0",onClick:()=>k(!f),children:f?e.jsx(b,{className:"h-4 w-4"}):e.jsx(C,{className:"h-4 w-4"})})]})]}),e.jsx(d,{type:"submit",className:"w-full",disabled:j,children:j?"Actualizando...":"Actualizar Contraseña"})]})})]}),e.jsx("div",{className:"text-center",children:e.jsx(d,{variant:"ghost",onClick:()=>r("/auth"),children:"Volver al inicio de sesión"})}),e.jsx("div",{className:"text-center text-xs text-gray-500",children:e.jsx("p",{children:"© 2024 FloraFlor. Todos los derechos reservados."})})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-green-50 to-blue-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(p,{className:"mx-auto h-12 w-12 text-red-600"}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Enlace Inválido"}),e.jsx("p",{className:"text-gray-600",children:"El enlace ha expirado o no es válido"}),e.jsx(d,{onClick:()=>r("/auth"),variant:"outline",children:"Volver al inicio de sesión"})]})})};export{G 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.