mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 23:27:31 +00:00
742c0dd72d
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.
31 lines
892 B
TypeScript
31 lines
892 B
TypeScript
import type React from 'react';
|
|
|
|
/**
|
|
* 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,
|
|
};
|
|
}
|