F
Filament12mo ago
Sourabh

Login Two Pannel Same Browser

I have created two in the filament one is Admin and another is App . is it possible to login both panel by same browser ?. 1)http://127.0.0.1:8000/admin/login 2)http://127.0.0.1:8000/app/login
6 Replies
toeknee
toeknee12mo ago
IT should work, but as I understand it tenants wouldn't
bogus
bogus12mo ago
@Sourabh use custom guard authentication https://laravel.com/docs/10.x/authentication#adding-custom-guards 1) /config/auth.php
return [
// ....

'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],

'back' => [
'driver' => 'session',
'provider' => 'admins',
],
],


'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],

'admins' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
// If necessary, a separate model can be used... or even a separate table
//'model' => App\Models\Admin::class,
],

// ....
]
return [
// ....

'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],

'back' => [
'driver' => 'session',
'provider' => 'admins',
],
],


'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],

'admins' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
// If necessary, a separate model can be used... or even a separate table
//'model' => App\Models\Admin::class,
],

// ....
]
3) And each Filament-panel uses a specific guard for authentication ->authGuard('***')
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->id('admin')
->path('admin')
->authGuard('back') //
// ...
;

}
// ....
}


class UserPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...()
->id('user')
->path('user')
->authGuard('web')
// ...
;

}
// ....
}
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->id('admin')
->path('admin')
->authGuard('back') //
// ...
;

}
// ....
}


class UserPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...()
->id('user')
->path('user')
->authGuard('web')
// ...
;

}
// ....
}
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
krekas
krekas12mo ago
no it won't work. either open browser in incognito mode or install different browser
Jordy
Jordy12mo ago
or split it to two apps
Sourabh
SourabhOP12mo ago
@bogus Thanks, it's working with the use of custom gaurd 👍
DrByte
DrByte12mo ago
Yes, it will work by specifying separate guards for each panel. Just be aware that when you use it this way, the Logout option may log you out of both guards (and therefore both panels) at the same time, even if RememberMe is set. This is because you're sharing the same session, because it's on the same domain. Beware that trying to split them into separate sessions while still sharing the same top-level-domain (regardless of subdomains) may take you down a very long road of exploration and discovery and frustration: easier to avoid that!
Want results from more Discord servers?
Add your server