"use client"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { client } from "@/lib/auth-client"; import { AlertCircle, CheckCircle2 } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; export default function Component() { const [totpCode, setTotpCode] = useState(""); const [error, setError] = useState(""); const [success, setSuccess] = useState(false); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (totpCode.length !== 6 || !/^\d+$/.test(totpCode)) { setError("TOTP code must be 6 digits"); return; } client.twoFactor .verifyTotp({ code: totpCode, }) .then((res) => { if (res.data?.session) { setSuccess(true); setError(""); } else { setError("Invalid TOTP code"); } }); }; return (
TOTP Verification Enter your 6-digit TOTP code to authenticate {!success ? (
setTotpCode(e.target.value)} placeholder="Enter 6-digit code" required />
{error && (
{error}
)}
) : (

Verification Successful

)}
); }