transcriptor-web/public/build/assets/TwoFactorChallenge-CSR_9ApP.js
2025-04-05 15:58:14 +02:00

2 lines
2.1 KiB
JavaScript

import{u as v,r as s,m as g,j as e,L as h}from"./app-43FwoUKv.js";import{c as j}from"./index-C3aXnQRR.js";import{A as b}from"./AuthenticationCard-CH5UMK9r.js";import{I as l}from"./InputLabel-Cl3yDvOx.js";import{P as C}from"./PrimaryButton-Gixff4KF.js";import{T as d,I as m}from"./TextInput-CdoY_jBz.js";import"./AuthenticationCardLogo-DxGGqaxw.js";function F(){const y=v(),[r,f]=s.useState(!1),t=g({code:"",recovery_code:""}),c=s.useRef(null),a=s.useRef(null);function x(o){o.preventDefault();const n=!r;f(n),setTimeout(()=>{var i,u;n?((i=c.current)==null||i.focus(),t.setData("code","")):((u=a.current)==null||u.focus(),t.setData("recovery_code",""))},100)}function p(o){o.preventDefault(),t.post(y("two-factor.login"))}return e.jsxs(b,{children:[e.jsx(h,{title:"Two-Factor Confirmation"}),e.jsx("div",{className:"mb-4 text-sm text-gray-600 dark:text-gray-400",children:r?"Please confirm access to your account by entering one of your emergency recovery codes.":"Please confirm access to your account by entering the authentication code provided by your authenticator application."}),e.jsxs("form",{onSubmit:p,children:[r?e.jsxs("div",{children:[e.jsx(l,{htmlFor:"recovery_code",children:"Recovery Code"}),e.jsx(d,{id:"recovery_code",type:"text",className:"mt-1 block w-full",value:t.data.recovery_code,onChange:o=>t.setData("recovery_code",o.currentTarget.value),ref:c,autoComplete:"one-time-code"}),e.jsx(m,{className:"mt-2",message:t.errors.recovery_code})]}):e.jsxs("div",{children:[e.jsx(l,{htmlFor:"code",children:"Code"}),e.jsx(d,{id:"code",type:"text",inputMode:"numeric",className:"mt-1 block w-full",value:t.data.code,onChange:o=>t.setData("code",o.currentTarget.value),autoFocus:!0,autoComplete:"one-time-code",ref:a}),e.jsx(m,{className:"mt-2",message:t.errors.code})]}),e.jsxs("div",{className:"flex items-center justify-end mt-4",children:[e.jsx("button",{type:"button",className:"text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 underline cursor-pointer",onClick:x,children:r?"Use an authentication code":"Use a recovery code"}),e.jsx(C,{className:j("ml-4",{"opacity-25":t.processing}),disabled:t.processing,children:"Log in"})]})]})]})}export{F as default};