F
Filament16mo ago
pratik

Tenant password reset token is being stored on landlord password_reset_tokens table.

I am using spatie's multitenancy [multi database setup] with filamentphp v3 with AdminPanel and TenantPanel, At the end of configuring and testing password resets I noticed that : for the password reset requested from tenant panel is being stored to landlord database's password_reset_tokens table, while the reset works just fine. I wonder what is causing this behavior ! , Everything works fine despite the tenant password resets being stored on landlord's table. The password reset mail just works with the tenant subdomain and the password reset is successfull but I find this behavior weird. I need some guidance. I am using different password brokers for landlord and tenant :
'providers' => [
'landlords' => [
'driver' => 'eloquent',
'model' => App\Models\Landlord\User::class,
],

'tenants' => [
'driver' => 'eloquent',
'model' => App\Models\Tenant\User::class,
],
],
'passwords' => [
'landlords' => [
'provider' => 'landlords',
'table' => 'password_reset_tokens',
'expire' => 60,
'throttle' => 60,
],
'tenants' => [
'provider' => 'tenants',
'table' => 'password_reset_tokens',
'expire' => 60,
'throttle' => 60,
],
],
'providers' => [
'landlords' => [
'driver' => 'eloquent',
'model' => App\Models\Landlord\User::class,
],

'tenants' => [
'driver' => 'eloquent',
'model' => App\Models\Tenant\User::class,
],
],
'passwords' => [
'landlords' => [
'provider' => 'landlords',
'table' => 'password_reset_tokens',
'expire' => 60,
'throttle' => 60,
],
'tenants' => [
'provider' => 'tenants',
'table' => 'password_reset_tokens',
'expire' => 60,
'throttle' => 60,
],
],
landlord password resets works too. Everything is working as expected.
1 Reply
pratik
pratikOP16mo ago
Here is my tenantPanelProvider's code :
return $panel
->domain()
->id('tenant')
->path('tenant')
->login()
->registration()
->passwordReset()
->authPasswordBroker('tenants')
->emailVerification()
->profile()
->colors([
'primary' => Color::Purple,
])
->discoverResources(in: app_path('Filament/Tenant/Resources'), for: 'App\\Filament\\Tenant\\Resources')
->discoverPages(in: app_path('Filament/Tenant/Pages'), for: 'App\\Filament\\Tenant\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Tenant/Widgets'), for: 'App\\Filament\\Tenant\\Widgets')
->widgets([
Widgets\AccountWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
\Spatie\Multitenancy\Http\Middleware\NeedsTenant::class,
\Spatie\Multitenancy\Http\Middleware\EnsureValidTenantSession::class,
])
->authGuard('tenant')
->authMiddleware([
Authenticate::class,
]);
}
return $panel
->domain()
->id('tenant')
->path('tenant')
->login()
->registration()
->passwordReset()
->authPasswordBroker('tenants')
->emailVerification()
->profile()
->colors([
'primary' => Color::Purple,
])
->discoverResources(in: app_path('Filament/Tenant/Resources'), for: 'App\\Filament\\Tenant\\Resources')
->discoverPages(in: app_path('Filament/Tenant/Pages'), for: 'App\\Filament\\Tenant\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Tenant/Widgets'), for: 'App\\Filament\\Tenant\\Widgets')
->widgets([
Widgets\AccountWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
\Spatie\Multitenancy\Http\Middleware\NeedsTenant::class,
\Spatie\Multitenancy\Http\Middleware\EnsureValidTenantSession::class,
])
->authGuard('tenant')
->authMiddleware([
Authenticate::class,
]);
}
Want results from more Discord servers?
Add your server