This commit is contained in:
diced
2025-11-03 15:29:53 -08:00
parent d3a417aff0
commit b014f10240

View File

@@ -27,9 +27,9 @@ export default function TwoFAButton() {
const [totpOpen, setTotpOpen] = useState(false); const [totpOpen, setTotpOpen] = useState(false);
const { const {
data: twoData, data: mfaData,
error: twoError, error: mfaError,
isLoading: twoLoading, isLoading: mfaLoading,
} = useSWR<Extract<Response['/api/user/mfa/totp'], { secret: string; qrcode: string }>>( } = useSWR<Extract<Response['/api/user/mfa/totp'], { secret: string; qrcode: string }>>(
totpOpen && !user?.totpSecret ? '/api/user/mfa/totp' : null, totpOpen && !user?.totpSecret ? '/api/user/mfa/totp' : null,
null, null,
@@ -51,7 +51,7 @@ export default function TwoFAButton() {
'POST', 'POST',
{ {
code: pin, code: pin,
secret: twoData!.secret, secret: mfaData!.secret,
}, },
); );
@@ -156,25 +156,20 @@ export default function TwoFAButton() {
</Text> </Text>
<Box pos='relative'> <Box pos='relative'>
{twoLoading && !twoError ? ( {mfaLoading && !mfaError ? (
<Box w={180} h={180}> <Box w={180} h={180}>
<LoadingOverlay visible pos='relative' /> <LoadingOverlay visible pos='relative' />
</Box> </Box>
) : ( ) : (
<Center> <Center>
<Image <Image h={180} w={180} src={mfaData?.qrcode} alt={'qr code ' + mfaData?.secret} />
width={180}
height={180}
src={twoData?.qrcode}
alt={'qr code ' + twoData?.secret}
/>
</Center> </Center>
)} )}
</Box> </Box>
<Text size='sm' c='dimmed'> <Text size='sm' c='dimmed'>
If you can&apos;t scan the QR code, you can manually enter the following code into your If you can&apos;t scan the QR code, you can manually enter the following code into your
authenticator app: <Code>{twoData?.secret ?? ''}</Code> authenticator app: <Code>{mfaData?.secret ?? ''}</Code>
</Text> </Text>
<Text size='sm' c='dimmed'> <Text size='sm' c='dimmed'>