Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

danisemet's avatar

Laravel 5.3 Multy Authentication

Please help me with this problem. i created an application using laravel 5.3. i need to make 3 user types, AdminSUper, Admin, and User. i have already create 3 guards with three different tables. I also make three different login pages for each user type. THE PROBLEM IS, Laravel Authentication always redirect all those three user to the same login page/url when they are loging out!!!. unlike Laravel 5.2, we can specify the " redirectAfterLogout" in the AuthCotroller so that each user types will be redirected to the different url of the login page that we have specified in the AuthCotroller .

i have exemined, and i foud the probliem is in the "Handler.php" inside "App\Exceptions" namespace. actually in the method

protected function unauthenticated($request, AuthenticationException $exception) { if ($request->expectsJson()) { return response()->json(['error' => 'Unauthenticated.'], 401); }

    return redirect()->guest('login');
}

did someone has found the same issue? Please help.

0 likes
10 replies
Yahav's avatar

@Hesto I'm highly interested in your package as well, how would we know when you're finished?

Hesto's avatar

@Yahav I had very little time at the weekend but working on it atm. Hope ill end it today, maybe tomorrow. I put it in this topic when i finish.

Yahav's avatar

Thanks, i just found out that my use case will be quite different, because i will use the secondary authentication with social login (hybridauth or laravel socialite) in which case, the authentication will be handled by the provider, however, i will still have to have the user stored somehow. which i have no idea how to achieve.

odylight's avatar

Hello @Hesto In addition to Multi-authentication service out of the box, how to provide a way to authorize user (Admin or Employee) actions against a given resource? Laravel's default Authorization approach does it in a simple way.

Hesto's avatar

@odylight You just want to know what is the difference between my package and Laravel's default multi auth, right? It's the same thing. You can setup it yourself using laravel's docs but its work for some long hours especially if you are not familliar with laravel or Laravel's multi-auth. You can also use my package to make setup for you with one simple command. Your choice :).

odylight's avatar

@Hesto we are misunderstood on this point. I know what your package done and i understand the purpose (may be not as well). But it's a difference between Authentication and Authorization, ok right? So i wondering about the fact, how can i set authorization through your package? or i don't need it because of separated tables?

Please or to participate in this conversation.