BEEEP/Auth/PM-35338 - Auto Submit on OTP Paste#20250
BEEEP/Auth/PM-35338 - Auto Submit on OTP Paste#20250JaredSnider-Bitwarden wants to merge 13 commits intomainfrom
Conversation
…ders When a code is pasted into the token input, set the form control value and programmatically click the continue button so the submission goes through the bitSubmit pipeline (loading state, disabled state) identically to a manual button click.
When a code is pasted into the OTP input, set the form control value and call submit() directly. The component owns both the input and submit(), so no parent wiring is needed.
Add pasteSubmit output to UserVerificationFormInputComponent, guarded to only fire in server-side OTP mode (passwordless users). The dialog handles the output by calling FormGroupDirective.onSubmit() so the submission goes through the bitSubmit pipeline with proper loading state. Note: auto-submit on paste for OTP verification applies to sensitive actions (vault export, disable 2FA, etc.) — pending product sign-off.
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed auto-submit-on-paste behavior added to four OTP entry flows: 2FA email, 2FA authenticator, new device verification, and the user verification dialog OTP. All four paths correctly route submission through the Code Review DetailsNo findings. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #20250 +/- ##
==========================================
- Coverage 47.09% 47.08% -0.02%
==========================================
Files 3948 3948
Lines 119684 119714 +30
Branches 18344 18358 +14
==========================================
- Hits 56370 56365 -5
- Misses 59080 59115 +35
Partials 4234 4234 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Great job! No new security vulnerabilities introduced in this pull request |
…line Use FormGroupDirective.onSubmit() instead of calling submit() directly so the bitSubmit directive handles loading state, form disabling, and error propagation consistently with the other auto-submit flows in this PR.
New outputs should use the signal-based output() function rather than the legacy @output() EventEmitter pattern.
|




🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-35338
📔 Objective
To add auto submit behavior on paste for the following scenarios:
Detailed Changes
Components — 2FA (Email & Authenticator)
libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-email.component.ts@Output() submitOnPaste = new EventEmitter<void>()— signals the parent to trigger form submission when a paste is detected.onPaste(event: ClipboardEvent)— extracts the pasted text, callsevent.preventDefault()to suppress the browser's default insertion, setstokenFormControldirectly viasetValue(), then emitssubmitOnPaste.libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-email.component.html(paste)="onPaste($event)"to the token input so paste events are intercepted before the browser inserts the text.libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-authenticator/two-factor-auth-authenticator.component.ts@Output() submitOnPaste = new EventEmitter<void>()andonPaste()— identical pattern to the email component; covers the TOTP copy-paste from a password manager scenario.libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-authenticator/two-factor-auth-authenticator.component.html(paste)="onPaste($event)"to the token input.libs/auth/src/angular/two-factor-auth/two-factor-auth.component.html(submitOnPaste)="continueButton?.nativeElement?.click()"on both<app-two-factor-auth-email>and<app-two-factor-auth-authenticator>— clicks the continue button programmatically rather than callingsubmit()directly, so the submission goes through thebitSubmitpipeline and loading/disabled state is managed correctly. This mirrors the existinghandleEnterKeyPresspattern.Components — New Device Verification
libs/auth/src/angular/new-device-verification/new-device-verification.component.tsonPaste(event: ClipboardEvent)— extracts pasted text, sets thecodeform control viasetValue(), and callsvoid this.submit()directly. No parent wiring is needed because this component owns both the input and the submit action.libs/auth/src/angular/new-device-verification/new-device-verification.component.html(paste)="onPaste($event)"to the OTP input field.Components — User Verification OTP
libs/auth/src/angular/user-verification/user-verification-form-input.component.ts@Output() pasteSubmit = new EventEmitter<void>()— emitted when a paste should trigger form submission.onPaste(event: ClipboardEvent)guarded byverificationType === "server" && userVerificationOptions.server.otp— only fires auto-submit for passwordless users shown the OTP input; master password, PIN, and biometrics inputs are unaffected. Sets the internal stringFormControldirectly so the ControlValueAccessor chain (processSecretChanges → onChange) updates the parent dialog'ssecretFormControl synchronously beforepasteSubmitemits.libs/auth/src/angular/user-verification/user-verification-form-input.component.html(paste)="onPaste($event)"to the server-side OTP text input only (inside the*ngIf="userVerificationOptions.server.otp"block).libs/auth/src/angular/user-verification/user-verification-dialog.component.ts@ViewChild(FormGroupDirective) private formGroupDirectiveto get a reference to the form's Angular directive.submitFromPaste()— callsformGroupDirective.onSubmit(new Event("submit"))to trigger submission through thebitSubmitpipeline (loading state, disabled state), identical to a button click. Callingsubmit()directly was avoided because it bypassesbitSubmit'sngSubmitsubscription.libs/auth/src/angular/user-verification/user-verification-dialog.component.html(pasteSubmit)="submitFromPaste()"on<app-user-verification-form-input>— the dialog is the only consumer of this output; other components that embedUserVerificationFormInputComponentdirectly are not affected.📸 Screenshots
2FA via Email
BEEEP.-.2FA.Auth.-.email.-.auto.submit.on.paste.mov
2FA via authenticator
BEEEP.-.2FA.Auth.-.authenticator.-.auto.submit.on.paste.mov
New device verification
BEEEP.-.NDV.-.auto.submit.on.paste.mov
User verification dialog for users without a MP - ex: vault export for a TDE user without a password.
BEEEP.-.UserVerificationDialog.vault.export.-.auto.submit.on.paste.mov