Skip to content

New users are blocked after enabling "Force MFA". #13238

Closed

Description

@newfolder0

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

Force MFA option makes it impossible to register new users.

Tested with Safari, Opera, and Firefox.
Not reproducible on the InvenTree demo site because the "Force MFA" option is disabled.

The problem is that when you create a new user, their email address is marked as "unvalidated". The new user can't register MFA without a valid email address, but they can't validate their email without setting up MFA.@⁨Jiri Vyskocil⁩il there is a workaround for now.

1.⁠ ⁠Create a new user
2.⁠ ⁠⁠Go to https://inventree.advantics.com/admin/account/emailaddress/
3.⁠ ⁠⁠Click on the new user's email
4.⁠ ⁠⁠Tick “validated”
5.⁠ ⁠⁠Click “Save”

Then the new user can set up MFA and log in.

Steps to Reproduce

  1. Admin switches “Force MFA” on in settings.

  2. Created a new user.

  3. New user receives an email with a link to Inventree, then clicks on the “reset password” function.

  4. New user receives a second email with a unique "password reset" link

  5. New user follows link in password reset email.

  6. Webpage returns only: {"id": "mfa_register", "error": "You must enable two-factor authentication before doing anything else."}

  7. New user clicks "back" button then "refresh".

  8. Browser shows partially loaded (broken) MFA registration page with space for QR code but no QR code.

Image Image

Expected behaviour

New user should be able to register MFA on their first login.

Workaround:

  1. After creating the new user account, administrator can go to https:///admin/account/emailaddress/
  2. Click on new user's email address
  3. Tick "validated"
  4. Click "Save" button

Deployment Method

Docker

Version Information

InvenTree-Version: 1.7.1
Django Version: 5.2.17
Commit Hash: 7507c45
Commit Date: 2026-11-08
Commit Branch: null
Database: django.db.backends.postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-6.12.116+deb13-amd64-x86_64-with-glibc2.41
Installer: DOC
Active plugins: [{"name":"InvenTreeBarcode","slug":"inventreebarcode","version":"2.2.0"},{"name":"BOM Exporter","slug":"bom-exporter","version":"1.1.0"},{"name":"InvenTree Exporter","slug":"inventree-exporter","version":"1.0.0"},{"name":"Parameter Exporter","slug":"parameter-exporter","version":"2.0.0"},{"name":"InvenTreeEmailNotifications","slug":"inventree-email-notification","version":"1.0.0"},{"name":"InvenTreeUINotifications","slug":"inventree-ui-notification","version":"1.0.0"},{"name":"InvenTreeWellKnown","slug":"inventree-well-known","version":"1.0.0"},{"name":"InvenTreeCurrencyExchange","slug":"inventreecurrencyexchange","version":"1.0.0"},{"name":"InvenTreeMachines","slug":"inventree-machines","version":"1.0.0"},{"name":"InvenTreeLabel","slug":"inventreelabel","version":"1.1.0"},{"name":"InvenTreeLabelMachine","slug":"inventreelabelmachine","version":"1.0.0"},{"name":"InvenTreeLabelSheet","slug":"inventreelabelsheet","version":"1.0.1"},{"name":"DigiKeyBarcodePlugin","slug":"digikeyplugin","version":"1.0.1"},{"name":"LCSCBarcodePlugin","slug":"lcscplugin","version":"1.0.1"},{"name":"MouserBarcodePlugin","slug":"mouserplugin","version":"1.0.1"},{"name":"TMEBarcodePlugin","slug":"tmeplugin","version":"1.0.1"},{"name":"AdvancedLabelSheet","slug":"advancedlabelsheet","version":"1.4.0"},{"name":"KiCadLibraryPlugin","slug":"kicad-library-plugin","version":"2.1.0"}]

Try to reproduce on the demo site

I tried to reproduce

Is the bug reproducible on the demo site?

Not reproducible

Relevant log output

I have reviewed this report for correctness and filled out all sections.

  • I have checked this report. I acknowledge that filing bugs via AI agents without review might lead to being blocked.

Activity

  1. added theissue type on Nov 9, 2026
  2. added
    bug
    question
    triage:not-checked
    on Nov 9, 2026
  3. newfolder0 commented on Nov 9, 2026

    @newfolder0
    Author

    With a bit of help from Claude AI, the problem seems to be that users with an unvalidated email address can't be served the MFA registration page.

    • When an admin creates a user, InvenTree saves their email as unverified (serializers.py:645). It then blocks password login and sends the “use the password reset function” email.
    • With “Force MFA” on, the middleware blocks every API call until MFA is set up.
    • django-allauth (65.19.6) won’t let a user enable MFA until their email is verified. InvenTree leaves allauth’s MFA_ALLOW_UNVERIFIED_EMAIL setting at its default of False (settings.py:1145).
    • Clicking on the password-reset link from the received email doesn’t mark the email as verified, and the MFA setup page gives the user no way to verify it.
    • User is stuck in a loop.

    @ timaraxian

  4. added
    security
    setup
    and removed
    triage:not-checked
    on Nov 10, 2026
  5. added this to the 1.8.0 milestone on Nov 10, 2026
  6. SchrodingersGat commented on Nov 10, 2026

    @SchrodingersGat
    Member

    @newfolder0 thanks for reporting. Potential fix incoming in #13241 - would you be able to test this?

  7. timaraxian commented on Nov 10, 2026

    @timaraxian

    Hi @SchrodingersGat, I'm one of @newfolder0's colleagues. I'm just confirming the changes in #13241 work for me.
    Cheers

  8. newfolder0 commented on Nov 10, 2026

    @newfolder0
    Author

    Rad, thanks both for knocking this over so quickly!
    I trust @timaraxian 's test and I don't have time to test it myself today - should I close the bug now, or wait until I've tested it myself (can do tomorrow, sorry for the delay) and/or it's released in the latest "stable" ?

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

    bugquestionsecuritysetup

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions