/** * Retrieve the response object for when authentication is missing. * * @since 1.0 * * @param Authenticatable $endpoint * * @return Response */ protected function generate_auth_missing(Authenticatable $endpoint) { $response = new Response(array('success' => false, 'error' => array('code' => $endpoint->get_auth_error_code(), 'message' => $endpoint->get_auth_error_message())), 401); switch ($endpoint->get_auth_mode()) { case Authenticatable::MODE_VALID_ACTIVATION: $realm = __("An active license key is required to access this resource, passed as the username, and the activation record ID as the password.", Plugin::SLUG); break; case Authenticatable::MODE_ACTIVE: $realm = __("An active license key is required to access this resource, passed as the username. Leave password blank.", Plugin::SLUG); break; case Authenticatable::MODE_EXISTS: default: $realm = __("A license key is required to access this resource, passed as the username. Leave password blank.", Plugin::SLUG); break; } $response->header('WWW-Authenticate', "Basic realm=\"{$realm}\""); return $response; }