Skip to content

BEEEP/Auth/PM-35338 - Auto Submit on OTP Paste#20250

Open
JaredSnider-Bitwarden wants to merge 13 commits intomainfrom
beeep/auth-paste-auto-submit
Open

BEEEP/Auth/PM-35338 - Auto Submit on OTP Paste#20250
JaredSnider-Bitwarden wants to merge 13 commits intomainfrom
beeep/auth-paste-auto-submit

Conversation

@JaredSnider-Bitwarden
Copy link
Copy Markdown
Contributor

@JaredSnider-Bitwarden JaredSnider-Bitwarden commented Apr 17, 2026

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-35338

📔 Objective

To add auto submit behavior on paste for the following scenarios:

  1. 2FA via Email
  2. 2FA via authenticator
  3. New device verification
  4. User verification dialog for users without a MP - ex: vault export for a TDE user without a password.

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

  1. Added @Output() submitOnPaste = new EventEmitter<void>() — signals the parent to trigger form submission when a paste is detected.
  2. Added onPaste(event: ClipboardEvent) — extracts the pasted text, calls event.preventDefault() to suppress the browser's default insertion, sets tokenFormControl directly via setValue(), then emits submitOnPaste.

libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-email.component.html

  1. Added (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

  1. Added @Output() submitOnPaste = new EventEmitter<void>() and onPaste() — 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

  1. Added (paste)="onPaste($event)" to the token input.

libs/auth/src/angular/two-factor-auth/two-factor-auth.component.html

  1. Added (submitOnPaste)="continueButton?.nativeElement?.click()" on both <app-two-factor-auth-email> and <app-two-factor-auth-authenticator> — clicks the continue button programmatically rather than calling submit() directly, so the submission goes through the bitSubmit pipeline and loading/disabled state is managed correctly. This mirrors the existing handleEnterKeyPress pattern.
Components — New Device Verification

libs/auth/src/angular/new-device-verification/new-device-verification.component.ts

  1. Added onPaste(event: ClipboardEvent) — extracts pasted text, sets the code form control via setValue(), and calls void 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

  1. Added (paste)="onPaste($event)" to the OTP input field.
Components — User Verification OTP

libs/auth/src/angular/user-verification/user-verification-form-input.component.ts

  1. Added @Output() pasteSubmit = new EventEmitter<void>() — emitted when a paste should trigger form submission.
  2. Added onPaste(event: ClipboardEvent) guarded by verificationType === "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 string FormControl directly so the ControlValueAccessor chain (processSecretChanges → onChange) updates the parent dialog's secret FormControl synchronously before pasteSubmit emits.

libs/auth/src/angular/user-verification/user-verification-form-input.component.html

  1. Added (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

  1. Added @ViewChild(FormGroupDirective) private formGroupDirective to get a reference to the form's Angular directive.
  2. Added submitFromPaste() — calls formGroupDirective.onSubmit(new Event("submit")) to trigger submission through the bitSubmit pipeline (loading state, disabled state), identical to a button click. Calling submit() directly was avoided because it bypasses bitSubmit's ngSubmit subscription.

libs/auth/src/angular/user-verification/user-verification-dialog.component.html

  1. Added (pasteSubmit)="submitFromPaste()" on <app-user-verification-form-input> — the dialog is the only consumer of this output; other components that embed UserVerificationFormInputComponent directly 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

…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.
@JaredSnider-Bitwarden JaredSnider-Bitwarden added the ai-review-vnext Request a Claude code review using the vNext workflow label Apr 17, 2026
@JaredSnider-Bitwarden JaredSnider-Bitwarden changed the title Beeep/auth paste auto submit BEEEP/Auth/PM-35338 - Auto Submit on OTP Paste Apr 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

🤖 Bitwarden Claude Code Review

Overall 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 bitSubmit pipeline — 2FA via continueButton.click() (mirroring the existing handleEnterKeyPress pattern), new-device-verification via viewChild(FormGroupDirective).onSubmit(), and user-verification-dialog via @ViewChild(FormGroupDirective).onSubmit(). Previously raised feedback about bitSubmit bypass in new-device-verification.component.ts is fully resolved on this revision. Paste handlers consistently use event.preventDefault(), trim input, short-circuit on empty values, and the user-verification handler is correctly gated on verificationType === "server" && userVerificationOptions.server.otp.

Code Review Details

No findings.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 5.55556% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.08%. Comparing base (b480007) to head (6662f75).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...-verification/new-device-verification.component.ts 0.00% 9 Missing ⚠️
...fication/user-verification-form-input.component.ts 0.00% 8 Missing ⚠️
...ticator/two-factor-auth-authenticator.component.ts 12.50% 7 Missing ⚠️
...ctor-auth-email/two-factor-auth-email.component.ts 12.50% 7 Missing ⚠️
...verification/user-verification-dialog.component.ts 0.00% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

Logo
Checkmarx One – Scan Summary & Detailsb4914f78-1848-4e1c-819f-29455176a3a0

Great job! No new security vulnerabilities introduced in this pull request

JaredSnider-Bitwarden and others added 3 commits April 17, 2026 19:55
…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.
@JaredSnider-Bitwarden JaredSnider-Bitwarden marked this pull request as ready for review April 27, 2026 15:17
@JaredSnider-Bitwarden JaredSnider-Bitwarden requested a review from a team as a code owner April 27, 2026 15:17
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review-vnext Request a Claude code review using the vNext workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant