The problem with the tenant_id not with the password
How are you logging in? and can you please share your listener code.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm following this tutorial. https://laracasts.com/series/multitenancy-in-practice/episodes/2
Created hashed password in UserFactory.
return [
'name' => fake()->name(),
'email' => fake()->safeEmail(),
'email_verified_at' => now(),
'role' => "admin",
'password' => Hash::make('password'), // password
'remember_token' => Str::random(10),
'tenant_id' => \App\Models\Tenant::factory()
];
When I run User factory for the first time for 10 users in tinker and set ['tenant_id' = 1], the "password" work fine for all 10 users. But when I don't add tenant_id, e.g: App\Models\User::factory(10)->create() the users don't work and display These credentials do not match our records. error.
Any idea what am I doing wrong?
Please note that, by following that tutorial, I created a listener which adds tenant_id to the session when the user login, and then a global scope returns records only for that tenant_id. Not sure if this issue could be related to that.
The problem is with the Session listener or retrieving tenant_id from the session. Not sure.
The problem is solved by getting tenant_id from Auth class Auth::user()->tenant_id instead of session.
Please or to participate in this conversation.