protected function user($request)
    {
        if (!$token = $this->auth->setRequest($request)->getToken()) {
            return 401;
        }

        try {
            $user = $this->auth->authenticate($token);
        } catch (JWTException $e) {
            return 401;
        }

        if (!$user) {
            return 401;
        }

        return $user;
    }