Middleware

User Module


Guest middleware

The guest middleware makes sure the current route can't be accessed by a logged in user.

By setting a route in the redirect_route_after_login config key in the config/asgard.user.users.php file, you can make the middleware redirect to your desired route. This defaults to homepage.

Example usage:

$router->get('login', [
    'middleware' => 'auth.guest', 
    'as' => 'login', 
    'uses' => 'AuthController@getLogin',
]);

Logged in middleware

The logged in middleware makes sure the current route can only be accessed by logged in users. This will redirect the user to the login page if it fails.

Example usage:

$router->group(['middleware' => 'logged.in'], function (Router $router) {
    $router->get('account', [
        'as' => 'user.account',
        'uses' => 'Frontend\ProfileController@show',
    ]);
});

Mobile Analytics