mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 13:10:29 +00:00
fix(login): the two-factor code field is set up for one-time codes and a password manager
The code step drops the email field, so a password manager had no login to match a one-time code to; the step now keeps the address in a hidden username field. The code field names itself and sets its keyboard hints directly (characters, no autocorrect), as autoFocus gave it focus before anything could prepare it, and its placeholder is translated.
This commit is contained in:
@@ -751,6 +751,19 @@ export default function LoginPage(): React.ReactElement {
|
||||
>
|
||||
{t('login.mfaCodeLabel')}
|
||||
</label>
|
||||
{/* The account the code belongs to, for password managers: they match a
|
||||
one-time code to a saved login through the username in the same form,
|
||||
and the email field is gone in this step. */}
|
||||
<input
|
||||
type="text"
|
||||
name="username"
|
||||
autoComplete="username"
|
||||
value={email}
|
||||
readOnly
|
||||
tabIndex={-1}
|
||||
aria-hidden="true"
|
||||
className="sr-only"
|
||||
/>
|
||||
<div style={{ position: 'relative' }}>
|
||||
<KeyRound
|
||||
size={15}
|
||||
@@ -765,13 +778,22 @@ export default function LoginPage(): React.ReactElement {
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
id="totp"
|
||||
name="totp"
|
||||
// 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.
|
||||
inputMode="text"
|
||||
autoComplete="one-time-code"
|
||||
autoCapitalize="characters"
|
||||
autoCorrect="off"
|
||||
spellCheck={false}
|
||||
enterKeyHint="go"
|
||||
value={mfaCode}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
|
||||
setMfaCode(e.target.value.toUpperCase().slice(0, 24))
|
||||
}
|
||||
placeholder="000000 or XXXX-XXXX"
|
||||
placeholder={t('login.mfaPlaceholder')}
|
||||
required
|
||||
autoFocus
|
||||
style={inputBase}
|
||||
|
||||
Reference in New Issue
Block a user