Ad

5.2 Out Of The Box Authentication Customization

- 1 answer

I'm new to laravel framework and I used the laravel-5.2 out of the box user authentication feature for creating a user authentication system. It is working fine. But when I want my home page to be displayed not the login page as the root. That is I want to access the login via the home page not the login page first. How can I customize my routes.

Ad

Answer

Just make sure that your home page route is not protected by the auth middleware. The default auth scaffolding provided by Laravel generates the following "home" route:

Route::get('/home', '[email protected]');

Inside the HomeController, in the constructor, is the following statement:

public function __construct()
{
    $this->middleware('auth');
}

This means that any route handled by this controller is subject to the auth middleware: if you're not logged in, you'll be redirected to the login page. So, if you don't want your "home" route to be protected by auth, you need to either remove the auth middleware from the HomeController, or create a new controller to handle your "home" route, one which does not use the auth middleware.

Ad
source: stackoverflow.com
Ad