Skip to content

Conversation

@pushpak1300
Copy link
Member

@pushpak1300 pushpak1300 commented Nov 18, 2025

This fixes a small papercut that happened when running the database seeder on a fresh installation. The seeder was creating a user with two factor enabled right away, which meant the user couldn’t log in.

@firebed
Copy link
Contributor

firebed commented Nov 18, 2025

Another perspective would be to remove the two_factor_* columns from the definition inside the UserFactory an rename the withoutTwoFactor to withTwoFactor and inverse the logic. This way the devs decide when to enable the 2fa functionality when writing tests and it's consistent with what happens when a user registers for the first time (the 2fa is disabled by default). Well, this is what I've been doing since the 2fa got integrated.

@pushpak1300
Copy link
Member Author

@firebed I had the same thought, but it ended up feeling inconsistent with the current factory model, especially with the existing unverified method:

@firebed
Copy link
Contributor

firebed commented Nov 18, 2025

I'm ok with this. Just expressing my opinion: The issue is that the user factory is creating users with two-factor authentication enabled by default. This means that any user created with User::factory() throughout the codebase (in tests, other seeders, or during development) will have 2FA enabled and won't be able to log in without additional configuration. Developers will need to remember to add ->withoutTwoFactor() everywhere they use the factory.
I believe this is exactly the issue you run into 🙂

@pushpak1300 pushpak1300 marked this pull request as draft November 18, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants