Skip to content

2FA code input: browser / password manager autofill keeps only the first digit #26608

Backlog

Description

@flegastelois

Code of Conduct

  • I agree to follow this project's Code of Conduct

Disable plugins

  • I reproduce the issue with all plugins disabled

Is there an existing issue for this?

  • I have searched the existing issues

Version

12.0.3 (code unchanged in 12.0/bugfixes and main)

Bug description

On the 2FA prompt, browsers and password managers can no longer fill the TOTP code: only the first digit is kept, the 5 other cells stay empty and the user has to type the code by hand. Reported by a user whose password manager filled the code on GLPI 11.0 and no longer does since the upgrade to 12.0.

The segmented code field (templates/twig_components/Mfa/CodeInput.html.twig, #24710) puts autocomplete="one-time-code" on its first cell, but:

  • autofill writes the whole code into that field and fires an input event, not a paste event. #onInput() in js/modules/Security/MfaCodeInput.js keeps value.replace(/\D/g, '').slice(0, 1), so 5 digits out of 6 are dropped. Only a real clipboard paste (#onPaste()) spreads the digits over the cells;
  • the first cell has maxlength="1", so password managers that "type" the code key by key into the one-time-code field are blocked after the first digit.

Expected: a code filled in the one-time-code cell is spread over the 6 cells, as on paste.

Page URL

/MFA/Prompt (same component in /MFA/Setup and in the password form)

Steps To reproduce

  1. Enable TOTP on a user.
  2. Log out, log in again to reach /MFA/Prompt.
  3. Let the browser / password manager fill the TOTP code. Without a password manager, run in the console:
    const first = document.querySelector('[autocomplete="one-time-code"]');
    first.value = '123456';
    first.dispatchEvent(new Event('input', { bubbles: true }));
  4. Only 1 remains in the first cell, the other cells are empty.

Activity

  1. added theissue type on Dec 4, 2026
  2. added this to the 12.0.4 milestone on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions