Helpers for managing multiple authentication guards in Laravel
iamproperty/laravel-multiauth is a Laravel package for helpers for managing multiple authentication guards in laravel.
It currently has 0 GitHub stars and 467 downloads on Packagist (latest version 1.1.1).
Install it with composer require iamproperty/laravel-multiauth.
Discover more Laravel packages by iamproperty
or browse all Laravel packages to compare alternatives.
Last updated
This will help automatically assigning the correct guard so that when you call Request::user() or Auth::user() there is no need to specify the guard.
Install the package using Composer.
composer install iamproperty/laravel-multiauth
Register the guard map:
class AuthServiceProvider
{
public function boot()
{
// ...
SetGuardHint::guardMap([
'agent' => \MoveButler\Agent::class,
]);
}
}
Register the login listener:
class EventServiceProvider
{
protected $listen = [
// ...
\Illuminate\Auth\Events\Login::class => [
\IAMProperty\MultiAuth\SetGuardHint::class,
],
// ...
Register the middleware:
class Kernel extends HttpKernel
{
protected $middlewareGroups = [
'web' => [
\Illuminate\Session\Middleware\StartSession::class,
// Add after the session is started
\IAMProperty\MultiAuth\SetGuardFromHint::class,
// ...
There is no need to configure anything manually, but if you want to you can publish the config file.
php artisan vendor:publish --provider="IAMProperty\MultiAuth\MultiAuthServiceProvider"