user(); throw_if(! $user || ! $user->root_admin, AccessDeniedHttpException::class, __('exceptions.api.unauthorized')); $token = $user->currentAccessToken(); if ($token instanceof HasAbilities && ! $token instanceof TransientToken) { throw_if($token->key_type === ApiKey::TYPE_APPLICATION, AccessDeniedHttpException::class, __('exceptions.api.application_key_rejected')); } return $next($request); } }