derrickrozay's avatar

How to use Tymons JWT-Auth with Laratrust/Entrust?

I am thinking about adding Laratrust to my Lumen 5.4 project. How difficult is to implement with JWT-Auth? Is it just as simple as doing this in the controller

if (JWTAuth::user()->hasRole('admin')) 
{
    // do something
}

How would I go about adding ACL to a route like this if the user has to be an admin but also authorized?

$app->group(['middleware' => ['auth']], function($app) {

    $app->get('/test', [
        'uses' => 'LoginController@getTestTable'
    ]);

Would I have to override any methods like for handling requests?

    public function handle($request, Closure $next, $guard = null)
    {
        if ($this->auth->guard($guard)->guest()) {
            return response('Unauthorized.', 401);
        }
        return $next($request);
    }
0 likes
1 reply
bdjunayed's avatar

Hi, have you solved this? I have the same issue here!

Please or to participate in this conversation.