user()->getAllPermissions() as $permission) { $scopes_check[] = $permission->name; } if (! $request->user() || ! $request->user()->token()) { throw new AuthenticationException; } if (in_array('*', $scopes_check)) { return $next($request); } foreach ($scopes as $scope) { if (! in_array($scope, $scopes_check)) { throw new AuthenticationException('Invalid scope(s) provided.'); } } return $next($request); } }