PageSourceSearch

https://fiquetranquiloenem.com/assets/MfaVerify-24adBMzy.js

js fiquetranquiloenem.com collected 2026-10-06 18:40:46 UTC 5,002 bytes, 1 lines download raw bytes

1import{r as i,u as U,b8 as T,j as e,a3 as j,l as M,aM as v,R as F,L as _,s}from"./index-BWsDOjhF.js";import{n as D}from"./notifyAdminLogin-BWKblHRh.js";import{C as G,a as P,b as K,d as q,c as z}from"./card-D5ucyWKc.js";import{I as B}from"./input-IZFF6cM3.js";import{K as y,I as H,a as $,b as o}from"./input-otp-B1CV8RP4.js";function Z(){const[l,m]=i.useState(""),[w,f]=i.useState(!1),[h,I]=i.useState(null),[L,R]=i.useState(!0),[u,N]=i.useState(!1),[x,C]=i.useState(""),[b,g]=i.useState(!1),r=U(),{toast:c}=T();i.useEffect(()=>{(async()=>{var S;const{data:a}=await s.auth.getSession();if(!(a!=null&&a.session)){r("/auth",{replace:!0});return}const{data:n,error:d}=await s.auth.mfa.listFactors();if(d||!((S=n==null?void 0:n.totp)!=null&&S.length)){r(d?"/auth":"/dashboard",{replace:!0});return}const p=n.totp.find(E=>E.status==="verified");if(!p){r("/dashboard",{replace:!0});return}I(p.id),R(!1)})()},[r]);const k=async()=>{const{data:{user:t}}=await s.auth.getUser();if(t){const{data:a}=await s.rpc("has_role",{_user_id:t.id,_role:"admin"});a===!0&&D(),r(a===!0?"/admin":"/dashboard",{replace:!0})}else r("/dashboard",{replace:!0})},O=async()=>{if(!h||l.length!==6)return;f(!0);const{data:t,error:a}=await s.auth.mfa.challenge({factorId:h});if(a){const d=a.message||"";/session/i.test(d)||a.status===401||a.status===403?(c({title:"Sessão expirada",description:"Faça login novamente para continuar.",variant:"destructive"}),await s.auth.signOut().catch(()=>{}),r("/auth",{replace:!0})):c({title:"Erro",description:d,variant:"destructive"}),f(!1);return}const{error:n}=await s.auth.mfa.verify({factorId:h,challengeId:t.id,code:l});if(n){c({title:"Código inválido",description:"Verifique o código no seu app autenticador e tente novamente.",variant:"destructive"}),m(""),f(!1);return}await k()},V=async()=>{if(!x.trim())return;g(!0);const{data:t,error:a}=await s.functions.invoke("mfa-recovery",{body:{code:x.trim()}});if(a||!(t!=null&&t.valid)){c({title:"Código inválido",description:(t==null?void 0:t.error)||"O código de recuperação não é válido ou já foi utilizado.",variant:"destructive"}),g(!1);return}c({title:"Acesso recuperado",description:`MFA desativado. Códigos restantes: ${t.remaining}. Reconfigure o autenticador no perfil.`}),await s.auth.refreshSession(),g(!1),await k()},A=async()=>{await s.auth.signOut(),r("/auth",{replace:!0})};return L?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx(j,{className:"w-8 h-8 animate-spin text-primary"})}):e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(G,{className:"w-full max-w-md",children:[e.jsxs(P,{className:"text-center space-y-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:M,alt:"Logo",className:"h-10"})}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:u?e.jsx(y,{className:"w-6 h-6 text-primary"}):e.jsx(v,{className:"w-6 h-6 text-primary"})})}),e.jsx(K,{className:"text-xl",children:u?"Código de recuperação":"Verificação em duas etapas"}),e.jsx(q,{children:u?"Digite um dos seus códigos de recuperação para acessar sua conta e desativar o MFA.":"Digite o código de 6 dígitos do seu aplicativo autenticador para continuar."})]}),e.jsxs(z,{className:"space-y-6",children:[u?e.jsxs(e.Fragment,{children:[e.jsx(B,{placeholder:"xxxxx-xxxxx",value:x,onChange:t=>C(t.target.value),className:"text-center font-mono text-lg tracking-widest",autoFocus:!0}),e.jsxs(F,{className:"w-full gap-2",onClick:V,disabled:!x.trim()||b,children:[b?e.jsx(j,{className:"w-4 h-4 animate-spin"}):e.jsx(y,{className:"w-4 h-4"}),"Usar código de recuperação"]}),e.jsxs("button",{type:"button",onClick:()=>{N(!1),C("")},className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground mx-auto transition-colors",children:[e.jsx(v,{className:"w-3.5 h-3.5"})," Usar app autenticador"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(H,{maxLength:6,value:l,onCh
1ange:m,autoFocus:!0,children:e.jsxs($,{children:[e.jsx(o,{index:0}),e.jsx(o,{index:1}),e.jsx(o,{index:2}),e.jsx(o,{index:3}),e.jsx(o,{index:4}),e.jsx(o,{index:5})]})})}),e.jsxs(F,{className:"w-full gap-2",onClick:O,disabled:l.length!==6||w,children:[w?e.jsx(j,{className:"w-4 h-4 animate-spin"}):e.jsx(v,{className:"w-4 h-4"}),"Verificar"]}),e.jsxs("button",{type:"button",onClick:()=>{N(!0),m("")},className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground mx-auto transition-colors",children:[e.jsx(y,{className:"w-3.5 h-3.5"})," Usar código de recuperação"]})]}),e.jsxs("button",{type:"button",onClick:A,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground mx-auto transition-colors",children:[e.jsx(_,{className:"w-3.5 h-3.5"})," Usar outra conta"]})]})]})})}export{Z 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.