@@ -5,13 +5,12 @@ import { useRouter, useSearchParams } from "next/navigation";
55import { createClientClientComponent } from "@/utils/supabase/client" ;
66import { Button } from "@/components/ui/button" ;
77import { Input } from "@codevs/ui/input" ;
8- import { ShieldCheck , KeyRound , ArrowLeft } from "lucide-react" ;
8+ import { ArrowLeft } from "lucide-react" ;
99import toast from "react-hot-toast" ;
1010
1111export default function TwoFactorForm ( ) {
1212 const [ supabase ] = useState ( ( ) => createClientClientComponent ( ) ) ;
1313 const [ code , setCode ] = useState ( "" ) ;
14- const [ isBackupMode , setIsBackupMode ] = useState ( false ) ;
1514 const [ isLoading , setIsLoading ] = useState ( false ) ;
1615 const [ factorId , setFactorId ] = useState < string | null > ( null ) ;
1716 const router = useRouter ( ) ;
@@ -45,21 +44,14 @@ export default function TwoFactorForm() {
4544 return ;
4645 }
4746
48- if ( ! factorId && ! isBackupMode ) {
47+ if ( ! factorId ) {
4948 toast . error ( "Authentication factor not ready. Please try logging in again." ) ;
5049 return ;
5150 }
5251
5352 setIsLoading ( true ) ;
5453
5554 try {
56- if ( isBackupMode ) {
57- // Backup Recovery Code check placeholder / code verification
58- toast . error ( "Invalid recovery code. Please check your backup codes or try TOTP." ) ;
59- setIsLoading ( false ) ;
60- return ;
61- }
62-
6355 // Standard TOTP Challenge & Verify
6456 const { data, error } = await supabase . auth . mfa . challengeAndVerify ( {
6557 factorId : factorId ! ,
@@ -90,14 +82,14 @@ export default function TwoFactorForm() {
9082 < form onSubmit = { handleSubmit } className = "mt-6 flex flex-col gap-4" >
9183 < div className = "space-y-2" >
9284 < label htmlFor = "2fa-code" className = "text-sm text-gray font-medium block text-center" >
93- { isBackupMode ? " Enter 9-character Recovery Code" : "Enter 6-digit Authenticator Code" }
85+ Enter 6-digit Authenticator Code
9486 </ label >
9587 < Input
9688 id = "2fa-code"
9789 type = "text"
98- placeholder = { isBackupMode ? "XXXX-XXXX" : " 123456"}
90+ placeholder = " 123456"
9991 value = { code }
100- maxLength = { isBackupMode ? 10 : 6 }
92+ maxLength = { 6 }
10193 onChange = { ( e ) => setCode ( e . target . value . trim ( ) ) }
10294 className = "text-center font-mono text-xl tracking-widest bg-dark-200 text-white border-dark-100 h-12"
10395 autoFocus
@@ -106,24 +98,17 @@ export default function TwoFactorForm() {
10698
10799 < Button
108100 type = "submit"
109- disabled = { isLoading || ( ! isBackupMode && code . length < 6 ) }
101+ disabled = { isLoading || code . length < 6 }
110102 className = "w-full bg-customBlue-100 text-white hover:bg-customBlue-200 h-11"
111103 >
112104 { isLoading ? "Verifying Identity..." : "Verify & Continue" }
113105 </ Button >
114106
115107 < div className = "flex flex-col gap-2 pt-2 text-center text-xs text-gray" >
116- < button
117- type = "button"
118- onClick = { ( ) => {
119- setIsBackupMode ( ! isBackupMode ) ;
120- setCode ( "" ) ;
121- } }
122- className = "text-customBlue-100 hover:underline flex items-center justify-center gap-1"
123- >
124- < KeyRound className = "w-3.5 h-3.5" />
125- { isBackupMode ? "Use Authenticator App Code instead" : "Use Backup Recovery Code" }
126- </ button >
108+ < p >
109+ Lost access to your authenticator app? Contact an admin to have 2FA
110+ reset on your account.
111+ </ p >
127112
128113 < button
129114 type = "button"
0 commit comments