Files
pterodactyl-panel/resources/scripts/components/dashboard/forms/RecoveryTokensDialog.tsx
T

53 lines
2.0 KiB
TypeScript
Raw Normal View History

2026-10-05 18:10:18 -04:00
import type { DialogProps } from '@/components/elements/dialog';
import { Dialog } from '@/components/elements/dialog';
import Button from '@/components/elements/Button';
2022-07-02 18:53:03 -04:00
import CopyOnClick from '@/components/elements/CopyOnClick';
import { Alert } from '@/components/elements/alert';
interface RecoveryTokenDialogProps extends DialogProps {
tokens: string[];
}
2026-10-05 18:10:18 -04:00
function RecoveryTokensDialog({ tokens, open, onClose }: RecoveryTokenDialogProps) {
2022-07-02 18:53:03 -04:00
const grouped = [] as [string, string][];
2026-10-08 16:53:20 -04:00
for (const [index, token] of tokens.entries()) {
2022-07-02 18:53:03 -04:00
if (index % 2 === 0) {
grouped.push([token, tokens[index + 1] || '']);
}
2026-10-08 16:53:20 -04:00
}
2022-07-02 18:53:03 -04:00
return (
<Dialog
open={open}
onClose={onClose}
2026-10-08 16:53:20 -04:00
title='Two-Step Authentication Enabled'
description='Store the codes below somewhere safe. If you lose access to your phone you can use these backup codes to sign in.'
2022-07-02 18:53:03 -04:00
hideCloseIcon
preventExternalClose
>
2026-10-08 16:53:20 -04:00
<Dialog.Icon position='container' type='success' />
2022-07-02 18:53:03 -04:00
<CopyOnClick text={tokens.join('\n')} showInNotification={false}>
2026-10-08 16:53:20 -04:00
<pre className='bg-background rounded-sm p-2 mt-6'>
2022-07-02 18:53:03 -04:00
{grouped.map((value) => (
2026-10-08 16:53:20 -04:00
<span key={value.join('_')} className='block'>
2022-07-02 18:53:03 -04:00
{value[0]}
2026-10-08 16:53:20 -04:00
<span className='mx-2 selection:bg-background'>&nbsp;</span>
2022-07-02 18:53:03 -04:00
{value[1]}
2026-10-08 16:53:20 -04:00
<span className='selection:bg-background'>&nbsp;</span>
2022-07-02 18:53:03 -04:00
</span>
))}
</pre>
</CopyOnClick>
2026-10-08 16:53:20 -04:00
<Alert type='danger' className='mt-3'>
2022-07-02 18:53:03 -04:00
These codes will not be shown again.
</Alert>
<Dialog.Footer>
<Button.Text onClick={onClose}>Done</Button.Text>
</Dialog.Footer>
</Dialog>
);
2026-10-05 18:10:18 -04:00
}
export default RecoveryTokensDialog;