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