Use as like below in your controller.
public function __construct()
{
$this->middleware('auth');
}
Hi Guys,
I am running Luman first time to test framework, I made login action that return api_token on success.
Then api_token is passed for further requests to endpoint under auth middleware. I would like to return message of my choice upon 401, whereas authentication middleware from handle method return Unauthorized for any Unauthorized request.
How can I return custom message?
Thanks in advanced.
Still not solved
Regards.
I still have a issue, even I add to controller constructor, then nothing happens.
According to my understanding
$this->middleware('auth');
or
// Routes requires auth
$router->group(['middleware' => 'auth'], function () use ($router) {
$router->get('auth/logout', 'User\AuthController@logout');
$router->get('user/profile', 'User\UserController@profile');
});
Both are equal and problem remain same, how to return custom unauthenticated messages.
Please or to participate in this conversation.