lundi 10 février 2020

Laravel 6 Error: Page not redirecting to the defined route

I've been stuck here for a while. I hope I can clearly explain the issue. I'm trying to have separate pages for admin and user. For that, I have created an admin middleware. Now when I login, it redirects me to the same page either its admin or user. I want it to go to admin dashboard when admin logs in and to the user home when user logs in. I hope the issue is clear. Here is the AdminMiddleware code:

public function handle($request, Closure $next)
    {
      if(Auth::user()->user_type == 'admin') //If usertype is admin
    {
       return $next($request);
    }
    else {
        return redirect('home');
    }
    }

Here are the routes code:

    Route::get('/','HomeController@index');
//For Admin
Route::group(['middleware' => ['auth','admin']], function() {

Route::get('/admin','HomeController@home_page');
Route::get('/users-list', 'UserController@users_list');

});

Here is the HomeController code:

public function index()
    {
return view('home', compact('currantWorkspace'));
}

I've added the Middleware path to kernel.php file.

I'll be happy to provide any other details if needed. Any solutions/suggestions will be highly appreciated.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/31HMbfb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire