Support the ongoing development of Laravel.io →
Authentication Laravel

Hello work on laravel 5.7 but i have a bug with the authentification, i have a admin middleware and a roles table, i add a role_id on my users table and add the logic for checkh the role and redirect the authenticated user but always be redirect to the homepage, here is my route file

Route::get('/', 'HomeController@index')->name('home');

Auth::routes();

Route::get('/confirm/{id}/{token}','Auth\RegisterController@confirm');

 

Route::group(['as'=>'admin.','prefix'=>'admin','namespace'=>'Admin','middleware'=>['auth','admin']], function (){
     Route::get('dashboard','DashboardController@index')->name('dashboard');
});

Login controller

public function __construct()
    {
        if (Auth::check() && Auth::user()->role_id == 1) {
            $this->redirectTo = route('admin.dashboard');
        } else {
            $this->redirectTo = route('agent.dashboard');
        }
        $this->middleware('guest')->except('logout');
    }

I modified the file ifredirectAuthenticated but nothing work get redirect to homepage

Last updated 3 years ago.
0

In LoginController:

public function redirectPath()
{
    return route('dashboard');
}
0

that's not solve the problem !

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.