My laravel version : 5.2
I want to override tymondesigns/jwt-auth GetUserFromToken.php
\vendor\tymon\jwt-auth\src\Middleware\GetUserFromToken.php
class GetUserFromToken extends BaseMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, \Closure $next)
{
if (! $token = $this->auth->setRequest($request)->getToken()) {
return $this->respond('tymon.jwt.absent', 'token_not_provided', 400);
}
For example, I want to return a custom message when token is not provided.
if (! $token = $this->auth->setRequest($request)->getToken()) {
return my_custom_message;
}
since I cannot make changes directly on this file, how should I create a custom class to override vendor's GetUserFromToken.php ?
Please describe required steps in detail if possible. Thanks.
via ethan17