Skip to content

Commit cd54721

Browse files
committed
login: auto-submit the 2FA form on the 6th digit
- the code input submits its form as soon as six digits are present, so no Sign in click after typing or autofilling - autocomplete=one-time-code enables iOS/macOS code suggestions - submitCode guards against double submission
1 parent 6f619ca commit cd54721

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

app/src/app/login/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default function Login() {
3737

3838
async function submitCode(e: FormEvent) {
3939
e.preventDefault();
40+
if (busy) return;
4041
setBusy(true);
4142
setError('');
4243
try {
@@ -110,10 +111,16 @@ function CodeInput({ code, setCode }: { code: string; setCode: (v: string) => vo
110111
return (
111112
<input
112113
inputMode="numeric"
114+
autoComplete="one-time-code"
113115
autoFocus
114116
maxLength={6}
115117
value={code}
116-
onChange={(e) => setCode(e.target.value.replace(/\D/g, ''))}
118+
onChange={(e) => {
119+
const v = e.target.value.replace(/\D/g, '');
120+
setCode(v);
121+
// Submit as soon as the 6th digit lands (also covers iOS code autofill).
122+
if (v.length === 6) e.target.form?.requestSubmit();
123+
}}
117124
placeholder="123456"
118125
className="field text-center text-lg tracking-[0.3em]"
119126
/>

0 commit comments

Comments
 (0)