Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/develop/resources/scripts/components/dashboard/forms/RecoveryTokensDialog.tsx
7454 views
1
import { Dialog, DialogProps } from '@/components/elements/dialog';
2
import { Button } from '@/components/elements/button/index';
3
import CopyOnClick from '@/components/elements/CopyOnClick';
4
import { Alert } from '@/components/elements/alert';
5
6
interface RecoveryTokenDialogProps extends DialogProps {
7
tokens: string[];
8
}
9
10
export default ({ tokens, open, onClose }: RecoveryTokenDialogProps) => {
11
const grouped = [] as [string, string][];
12
tokens.forEach((token, index) => {
13
if (index % 2 === 0) {
14
grouped.push([token, tokens[index + 1] || '']);
15
}
16
});
17
18
return (
19
<Dialog
20
open={open}
21
onClose={onClose}
22
title={'Two-Step Authentication Enabled'}
23
description={
24
'Store the codes below somewhere safe. If you lose access to your phone you can use these backup codes to sign in.'
25
}
26
hideCloseIcon
27
preventExternalClose
28
>
29
<Dialog.Icon position={'container'} type={'success'} />
30
<CopyOnClick text={tokens.join('\n')} showInNotification={false}>
31
<pre className={'mt-6 rounded bg-slate-800 p-2'}>
32
{grouped.map(value => (
33
<span key={value.join('_')} className={'block'}>
34
{value[0]}
35
<span className={'mx-2 selection:bg-slate-800'}>&nbsp;</span>
36
{value[1]}
37
<span className={'selection:bg-slate-800'}>&nbsp;</span>
38
</span>
39
))}
40
</pre>
41
</CopyOnClick>
42
<Alert type={'danger'} className={'mt-3'}>
43
These codes will not be shown again.
44
</Alert>
45
<Dialog.Footer>
46
<Button.Text onClick={onClose}>Done</Button.Text>
47
</Dialog.Footer>
48
</Dialog>
49
);
50
};
51
52