PageSourceSearch

https://penbrief.com/build/assets/TwoFactorForm-lVrYYjW7.js

js penbrief.com collected 2026-10-08 05:35:17 UTC 6,108 bytes, 2 lines download raw bytes

1import{j as e}from"./app-Bn8axf2m.js";import{u as l,r as g}from"./vendor-D8BamyIx.js";import{I as m}from"./InputError-9fJul_yf.js";import{B as N}from"./badge-DSA_tntd.js";import{B as a}from"./button-BJHJ0j8Y.js";import{C,b as _,c as S,d as k,a as D}from"./card-D0Qy6Ld2.js";import{I as p}from"./input-Jv8uXHpu.js";import{L as c}from"./label-Cg1Qz0vJ.js";import{S as w}from"./shield-check-DX9si8b9.js";import{T as z}from"./triangle-alert-P9Ytexve.js";import{C as T}from"./check-s0EwGkyq.js";import{K as E}from"./key-round-CZTcUnqO.js";import{c as F}from"./createLucideIcon-CsuOtgaI.js";/* empty css            */import"./utils-DCADjnpI.js";import"./index-xw87Tvjh.js";import"./index-CPzEHnIt.js";const R=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],I=F("shield-off",R);function Z({state:r}){const o=l({password:""}),t=l({code:""}),n=l({password:""}),i=l({password:""}),[x,h]=g.useState(!1),[u,f]=g.useState(!1),d={preserveScroll:!0},j=s=>{s.preventDefault(),o.post("/profile/two-factor",{...d,onSuccess:()=>o.reset()})},y=s=>{s.preventDefault(),t.post("/profile/two-factor/confirm",{...d,onSuccess:()=>t.reset()})},b=s=>{s.preventDefault(),i.post("/profile/two-factor/recovery-codes",{...d,onSuccess:()=>{i.reset(),f(!1)}})},v=s=>{s.preventDefault(),n.delete("/profile/two-factor",{...d,onSuccess:()=>{n.reset(),h(!1)}})};return e.jsxs(C,{children:[e.jsxs(_,{children:[e.jsxs(S,{className:"flex items-center gap-2",children:["Two-factor authentication",r.enabled&&e.jsxs(N,{variant:"outline",className:"gap-1 border-emerald-500/30 text-emerald-600",children:[e.jsx(w,{className:"size-3"}),"On"]})]}),e.jsx(k,{children:"A code from your phone, in addition to your password. Uses any authenticator app — nothing is sent by SMS or email."})]}),e.jsxs(D,{className:"space-y-6",children:[r.recovery_codes&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-500/40 bg-amber-500/5 p-4",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm font-medium",children:[e.jsx(z,{className:"mt-0.5 size-4 shrink-0 text-amber-600"}),"Save these recovery codes now"]}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"They are shown once and never again. Each works a single time, and they are the only way back in if you lose your device."}),e.jsx("div",{className:"grid grid-cols-2 gap-1 font-mono text-sm",children:r.recovery_codes.map(s=>e.jsx("code",{className:"bg-background rounded px-2 py-1",children:s},s))}),e.jsx(a,{type:"button",size:"sm",variant:"outline",onClick:()=>navigator.clipboard?.writeText((r.recovery_codes??[]).join(`
2`)),children:"Copy codes"})]}),r.pending&&r.qr&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm",children:"Scan this with your authenticator app, then enter the code it shows."}),e.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[e.jsx("div",{className:"rounded-lg border bg-white p-3 [&_svg]:block",dangerouslySetInnerHTML:{__html:r.qr}}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xs",children:"Can’t scan? Enter this key manually:"}),e.jsx("code",{className:"bg-muted block rounded px-2 py-1 font-mono text-xs break-all",children:r.secret})]})]}),e.jsxs("form",{onSubmit:y,className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"tf_code",children:"Code"}),e.jsx(p,{id:"tf_code",value:t.data.code,onChange:s=>t.setData("code",s.target.value),inputMode:"numeric",maxLength:6,className:"w-36 text-center font-mono tracking-[0.3em]",placeholder:"000000"})]}),e.jsxs(a,{type:"submit",disabled:t.processing,children:[e.jsx(T,{className:"size-4"}),"Confirm"]})]}),e.jsx(m,{message:t.errors.code})]}),!r.enabled&&!r.pending&&e.jsxs("form",{onSubmit:j,className:"space-y-3",children:[e.jsxs("div",{className:"max-w-sm space-y-2",children:[e.jsx(c,{htmlFor:"tf_enable_password",children:"Current password"}),e.jsx(p,{id:"tf_enable_password",type:"password",autoComplete:"current-password",value:o.data.password,onChange:s=>o.setData("password",s.target.value)}),e.jsx(m,{message:o.errors.password})]}
2),e.jsxs(a,{type:"submit",disabled:o.processing,children:[e.jsx(w,{className:"size-4"}),"Enable two-factor"]})]}),r.enabled&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-muted-foreground flex items-center gap-2 text-sm",children:[e.jsx(E,{className:"size-4"}),r.recovery_codes_remaining," recovery code",r.recovery_codes_remaining===1?"":"s"," remaining.",r.recovery_codes_remaining<=2&&" Consider regenerating them."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(a,{type:"button",variant:"outline",size:"sm",onClick:()=>f(!u),children:"Regenerate recovery codes"}),e.jsxs(a,{type:"button",variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>h(!x),children:[e.jsx(I,{className:"size-4"}),"Turn off"]})]}),u&&e.jsxs("form",{onSubmit:b,className:"max-w-sm space-y-2 rounded-lg border p-3",children:[e.jsx(c,{htmlFor:"tf_regen_password",children:"Confirm with your password"}),e.jsx(p,{id:"tf_regen_password",type:"password",autoComplete:"current-password",value:i.data.password,onChange:s=>i.setData("password",s.target.value)}),e.jsx(m,{message:i.errors.password}),e.jsx(a,{type:"submit",size:"sm",disabled:i.processing,children:"Regenerate"})]}),x&&e.jsxs("form",{onSubmit:v,className:"border-destructive/40 max-w-sm space-y-2 rounded-lg border p-3",children:[e.jsx(c,{htmlFor:"tf_disable_password",children:"Confirm with your password"}),e.jsx(p,{id:"tf_disable_password",type:"password",autoComplete:"current-password",value:n.data.password,onChange:s=>n.setData("password",s.target.value)}),e.jsx(m,{message:n.errors.password}),e.jsx(a,{type:"submit",size:"sm",variant:"destructive",disabled:n.processing,children:"Turn off two-factor"})]})]})]})]})}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.