mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix(login): keep the app sign-in screen within the eslint ratchets
Split the other ways in out of one component (complexity), finish the async handlers with void instead of handing promises to React, report a landscape that fails to load instead of logging it, let the handover wait on settled settings rather than catching them, and move the one-time code field's props into a module of their own so MfaCodeStep only exports its component.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { KeyRound } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { mfaCodeInputProps } from './mfaCodeInput';
|
||||
|
||||
interface MfaCodeStepProps {
|
||||
/** The account being signed in, kept in the form for password managers. */
|
||||
@@ -11,35 +12,6 @@ interface MfaCodeStepProps {
|
||||
onBack: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The one-time code field, for this step and the app's sign-in screen alike.
|
||||
* Text, not numeric: backup codes carry letters. The hints are set here rather
|
||||
* than left to native/keyboardFields.ts, because autoFocus gives the field
|
||||
* focus before any touch could prepare it.
|
||||
*/
|
||||
export function mfaCodeInputProps(
|
||||
code: string,
|
||||
onCode: (code: string) => void,
|
||||
placeholder: string
|
||||
): React.InputHTMLAttributes<HTMLInputElement> {
|
||||
return {
|
||||
type: 'text',
|
||||
id: 'totp',
|
||||
name: 'totp',
|
||||
inputMode: 'text',
|
||||
autoComplete: 'one-time-code',
|
||||
autoCapitalize: 'characters',
|
||||
autoCorrect: 'off',
|
||||
spellCheck: false,
|
||||
enterKeyHint: 'go',
|
||||
value: code,
|
||||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => onCode(e.target.value.toUpperCase().slice(0, 24)),
|
||||
placeholder,
|
||||
required: true,
|
||||
autoFocus: true,
|
||||
};
|
||||
}
|
||||
|
||||
/** The login's second step: the one-time or backup code, and the way back. */
|
||||
export default function MfaCodeStep({ email, code, onCode, inputStyle, onBack }: MfaCodeStepProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
Reference in New Issue
Block a user