mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 14:43:06 +08:00
dcbb65d799
* LDAP - WIP * WIP * add hasGeneratedPassword * fix jotai atom * - don't require password confirmation for MFA is user has auto generated password (LDAP) - cleanups * fix * reorder * update migration * update default * fix type error
82 lines
1.7 KiB
TypeScript
82 lines
1.7 KiB
TypeScript
import React from "react";
|
|
import {
|
|
TextInput,
|
|
Button,
|
|
Stack,
|
|
Text,
|
|
Alert,
|
|
} from "@mantine/core";
|
|
import { IconKey, IconAlertCircle } from "@tabler/icons-react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
interface MfaBackupCodeInputProps {
|
|
value: string;
|
|
onChange: (value: string) => void;
|
|
error?: string;
|
|
onSubmit: () => void;
|
|
onCancel: () => void;
|
|
isLoading?: boolean;
|
|
}
|
|
|
|
export function MfaBackupCodeInput({
|
|
value,
|
|
onChange,
|
|
error,
|
|
onSubmit,
|
|
onCancel,
|
|
isLoading,
|
|
}: MfaBackupCodeInputProps) {
|
|
const { t } = useTranslation();
|
|
|
|
return (
|
|
<Stack>
|
|
<Alert icon={<IconAlertCircle size={16} />} color="blue" variant="light">
|
|
<Text size="sm">
|
|
{t(
|
|
"Enter one of your backup codes. Each backup code can only be used once.",
|
|
)}
|
|
</Text>
|
|
</Alert>
|
|
|
|
<TextInput
|
|
label={t("Backup code")}
|
|
placeholder="XXXXXXXX"
|
|
value={value}
|
|
onChange={(e) => onChange(e.currentTarget.value.toUpperCase())}
|
|
error={error}
|
|
autoFocus
|
|
data-autofocus
|
|
maxLength={8}
|
|
styles={{
|
|
input: {
|
|
fontFamily: "monospace",
|
|
letterSpacing: "0.1em",
|
|
fontSize: "1rem",
|
|
},
|
|
}}
|
|
/>
|
|
|
|
<Stack>
|
|
<Button
|
|
fullWidth
|
|
size="md"
|
|
loading={isLoading}
|
|
onClick={onSubmit}
|
|
leftSection={<IconKey size={18} />}
|
|
>
|
|
{t("Verify backup code")}
|
|
</Button>
|
|
|
|
<Button
|
|
fullWidth
|
|
variant="subtle"
|
|
color="gray"
|
|
onClick={onCancel}
|
|
disabled={isLoading}
|
|
>
|
|
{t("Use authenticator app instead")}
|
|
</Button>
|
|
</Stack>
|
|
</Stack>
|
|
);
|
|
} |