Files
biiproject-kit-v2/public/build/assets/Setup-DtB1W1gN.js
T

1 line
8.3 KiB
JavaScript

import{a as e,c as t,d as n,i as r,n as i,t as a}from"./app-CBC6ZGaO.js";import{t as o}from"./AuthenticatedLayout-DI4WLw0Y.js";import{n as s,t as c}from"./swal-ClfUb7Hm.js";var l=n(t(),1),u=n(s(),1),d=a();function f({enabled:t,qr_code:n,secret:a,recovery_codes:s}){let[f,p]=(0,l.useState)(!1),[m,h]=(0,l.useState)(!1),{data:g,setData:_,post:v,processing:y,errors:b,reset:x}=e({code:``});return e({password:``}),(0,d.jsxs)(o,{children:[(0,d.jsx)(i,{title:`Two-Factor Authentication`}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between mb-8 anim-down`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h1`,{className:`text-xl font-bold text-[#3D4E4B] dark:text-white tracking-tight leading-none`,children:`Two-Factor Authentication`}),(0,d.jsx)(`p`,{className:`text-sm font-semibold text-gray-400 tracking-tight mt-2`,children:`Protect your account with an additional verification step`})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold ${t?`bg-emerald-50 text-emerald-700 border border-emerald-200`:`bg-amber-50 text-amber-700 border border-amber-200`}`,children:[(0,d.jsx)(`span`,{className:`w-2 h-2 rounded-full ${t?`bg-emerald-500`:`bg-amber-400`}`}),t?`2FA Active`:`2FA Not Enabled`]})]}),(0,d.jsxs)(`div`,{className:`max-w-3xl space-y-6`,children:[(0,d.jsxs)(`div`,{className:`p-5 bg-amber-50 border border-amber-200 rounded-2xl flex items-start gap-3 anim-down`,children:[(0,d.jsx)(`svg`,{className:`w-5 h-5 text-amber-500 mt-0.5 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,d.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v2m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z`})}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-bold text-amber-800 mb-1`,children:`What is Two-Factor Authentication?`}),(0,d.jsx)(`p`,{className:`text-[11px] text-amber-700 font-medium leading-relaxed`,children:`2FA adds an extra layer of security by requiring a one-time code from your authenticator app in addition to your password when signing in.`})]})]}),t?(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{className:`bg-white rounded-2xl border border-emerald-100 shadow-sm p-6 flex items-center gap-4 anim-up`,children:[(0,d.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-emerald-50 flex items-center justify-center shrink-0`,children:(0,d.jsx)(`svg`,{className:`w-6 h-6 text-emerald-600`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,d.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z`})})}),(0,d.jsxs)(`div`,{className:`flex-1`,children:[(0,d.jsx)(`div`,{className:`text-sm font-bold text-[#3D4E4B]`,children:`Two-Factor Authentication is Active`}),(0,d.jsx)(`div`,{className:`text-xs text-gray-400 font-medium mt-0.5`,children:`Your account is secured with TOTP authentication.`})]}),(0,d.jsx)(`button`,{onClick:async()=>{let{value:e}=await u.default.fire({title:`Disable 2FA`,text:`Enter your password to confirm disabling Two-Factor Authentication.`,input:`password`,inputPlaceholder:`Your current password`,showCancelButton:!0,confirmButtonText:`Disable`,confirmButtonColor:`#dc2626`});e&&r.post(route(`two-factor.disable`),{password:e},{preserveScroll:!0,onSuccess:()=>c.success(`Disabled`,`2FA has been disabled.`)})},className:`h-9 px-5 text-xs font-bold text-red-500 border border-red-200 rounded-xl hover:bg-red-50 transition-all`,children:`Disable 2FA`})]}),(0,d.jsxs)(`div`,{className:`bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden anim-up`,style:{animationDelay:`0.05s`},children:[(0,d.jsxs)(`div`,{className:`px-6 py-4 border-b border-gray-50 bg-gray-50/30 flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h2`,{className:`text-sm font-bold text-[#3D4E4B]`,children:`Recovery Codes`}),(0,d.jsx)(`p`,{className:`text-xs text-gray-400 font-semibold mt-1`,children:`Store these codes safely — use them if you lose access to your authenticator`})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`button`,{onClick:()=>h(!m),className:`h-8 px-4 text-xs font-bold text-[#3D4E4B] border border-gray-200 rounded-lg hover:bg-gray-50 transition-all`,children:m?`Hide`:`Show`}),(0,d.jsx)(`button`,{onClick:async()=>{(await c.confirm(`Regenerate Codes?`,`Old recovery codes will be invalidated immediately.`,`Regenerate`)).isConfirmed&&r.post(route(`two-factor.recovery-codes`),{},{preserveScroll:!0,onSuccess:()=>{h(!0),c.success(`Regenerated`,`New recovery codes have been generated.`)}})},className:`h-8 px-4 text-xs font-bold text-[#D4A017] border border-amber-200 rounded-lg hover:bg-amber-50 transition-all`,children:`Regenerate`})]})]}),m&&s.length>0&&(0,d.jsxs)(`div`,{className:`p-6`,children:[(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:s.map((e,t)=>(0,d.jsx)(`code`,{className:`px-4 py-2.5 bg-gray-50 border border-gray-100 rounded-xl text-xs font-mono text-[#3D4E4B] tracking-wider text-center`,children:e},t))}),(0,d.jsx)(`p`,{className:`text-[11px] text-amber-600 font-semibold mt-4`,children:`⚠ Each code can only be used once. Regenerate if compromised.`})]})]})]}):(0,d.jsxs)(`div`,{className:`bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden anim-up`,children:[(0,d.jsxs)(`div`,{className:`px-6 py-4 border-b border-gray-50 bg-gray-50/30`,children:[(0,d.jsx)(`h2`,{className:`text-sm font-bold text-[#3D4E4B]`,children:`Setup Authenticator App`}),(0,d.jsx)(`p`,{className:`text-xs text-gray-400 font-semibold mt-1`,children:`Scan the QR code with Google Authenticator, Authy, or any TOTP app`})]}),(0,d.jsx)(`div`,{className:`p-8`,children:(0,d.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-10 items-center md:items-start`,children:[(0,d.jsx)(`div`,{className:`shrink-0`,children:(0,d.jsx)(`div`,{className:`p-4 bg-white border-2 border-gray-100 rounded-2xl inline-block shadow-sm`,children:(0,d.jsx)(`img`,{src:n,alt:`2FA QR Code`,className:`w-48 h-48`})})}),(0,d.jsxs)(`div`,{className:`flex-1 space-y-6`,children:[(0,d.jsx)(`div`,{className:`space-y-4`,children:[`Install an authenticator app (Google Authenticator, Authy, 1Password)`,`Scan the QR code or enter the manual key below`,`Enter the 6-digit code from your app to verify and activate`].map((e,t)=>(0,d.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-[#3D4E4B] text-white text-[10px] font-black flex items-center justify-center shrink-0 mt-0.5`,children:t+1}),(0,d.jsx)(`p`,{className:`text-xs font-medium text-gray-500 leading-relaxed pt-0.5`,children:e})]},t))}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-semibold text-gray-400 mb-1.5`,children:`Manual Key`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`code`,{className:`flex-1 text-xs font-mono bg-gray-50 border border-gray-100 rounded-xl px-4 py-3 text-[#3D4E4B] tracking-wider`,children:a}),(0,d.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(a),p(!0),setTimeout(()=>p(!1),2e3)},className:`shrink-0 h-11 px-4 border border-gray-200 rounded-xl text-xs font-bold text-gray-500 hover:bg-gray-50 transition-all`,children:f?`✓ Copied`:`Copy`})]})]}),(0,d.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),v(route(`two-factor.enable`),{preserveScroll:!0,onSuccess:()=>{x(),c.success(`Enabled`,`2FA is now active on your account.`)}})},className:`space-y-3`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-xs font-semibold text-gray-400 mb-1.5`,children:`Verification Code *`}),(0,d.jsx)(`input`,{type:`text`,inputMode:`numeric`,maxLength:6,value:g.code,onChange:e=>_(`code`,e.target.value),className:`input-field w-full text-center tracking-[0.5em] font-bold text-lg`,placeholder:`000000`}),b.code&&(0,d.jsx)(`p`,{className:`text-xs text-red-500 font-semibold mt-1`,children:b.code})]}),(0,d.jsx)(`button`,{type:`submit`,disabled:y||g.code.length<6,className:`w-full h-11 bg-[#3D4E4B] text-white text-xs font-bold rounded-xl hover:bg-[#2D3A38] transition-all disabled:opacity-60`,children:y?`Verifying...`:`Enable Two-Factor Authentication`})]})]})]})})]})]})]})}export{f as default};