Support the ongoing development of Laravel.io →
Authentication Requests Session
Last updated 1 year ago.
0

trevodo said:

The first route is hit, Auth::check() returns false so the block moves on to creating the login page.

Route::get('/', function()
{
   if (Auth::check()) 
   {
   	if(Auth::user()->hasRole('employee'))
   	{
   		return Redirect::to('Employees/Shifts');
   	}
   	else
   	{
          
   		return Redirect::to('Admin/Employees');
   	}
       	
   } 
   else 
   {
       return View::make('login');
   }
});

The issue is that the routes are generated before the Auth is initiated. Essentially, Auth::check() will always be false. This check must be done instead in Laravel 5's middleware or Laravel 3-4's filters.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

trevodo trevodo Joined 26 Nov 2014

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.

© 2024 Laravel.io - All rights reserved.