-
Notifications
You must be signed in to change notification settings - Fork 249
Disable two-factor authentication for test user in DatabaseSeeder #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Another perspective would be to remove the |
|
@firebed I had the same thought, but it ended up feeling inconsistent with the current factory model, especially with the existing |
|
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 |
|
I think I know why we get invalid payload error when login using test user. It is because the value of It should be: return [
...
'two_factor_secret' => encrypt(Str::random(10)),
'two_factor_recovery_codes' => encrypt(Str::random(10)),
'two_factor_confirmed_at' => now(),
];The problem is, we wouldn't know the secret to generate 2FA codes 😅 I tried to I agree with @firebed perspective on how it should be done in the first place and feel the same with @pushpak1300. I think @pushpak1300 solution is the most effective one-line solution if we don't want to refactor the code too much 😂 |
|
For anyone coming across this and only uses the User factory for non-prod, just update the 2fa secret and recovery code to some basic plain text values. Then use the recovery code to login. database/factories/UserFactory.php |
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.