summaryrefslogtreecommitdiff
path: root/lib/apiauth.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-07-16 14:40:22 -0700
committerZach Copley <zach@status.net>2010-07-16 14:40:22 -0700
commit65862d8f7f45d487d4714137af96d3a24e4ca386 (patch)
tree5802cb47b0aaec09af0115d3fd857142e4c2a5f6 /lib/apiauth.php
parentd73feb82d89d66593fd81f8bb5d10b1873fc9458 (diff)
Suppress HTTP error headers for JSONP API output
Diffstat (limited to 'lib/apiauth.php')
-rw-r--r--lib/apiauth.php38
1 files changed, 3 insertions, 35 deletions
diff --git a/lib/apiauth.php b/lib/apiauth.php
index 91cb64262..cf7a2692c 100644
--- a/lib/apiauth.php
+++ b/lib/apiauth.php
@@ -227,7 +227,7 @@ class ApiAuthAction extends ApiAction
} catch (OAuthException $e) {
common_log(LOG_WARNING, 'API OAuthException - ' . $e->getMessage());
- $this->showAuthError();
+ $this->clientError($e->getMessage(), 401, $this->format);
exit;
}
}
@@ -265,7 +265,7 @@ class ApiAuthAction extends ApiAction
// show error if the user clicks 'cancel'
- $this->showAuthError();
+ $this->clientError("Could not authenticate you.", 401, $this->format);
exit;
} else {
@@ -298,7 +298,7 @@ class ApiAuthAction extends ApiAction
$proxy,
$ip);
common_log(LOG_WARNING, $msg);
- $this->showAuthError();
+ $this->clientError("Could not authenticate you.", 401, $this->format);
exit;
}
}
@@ -345,36 +345,4 @@ class ApiAuthAction extends ApiAction
}
}
}
-
- /**
- * Output an authentication error message. Use XML or JSON if one
- * of those formats is specified, otherwise output plain text
- *
- * @return void
- */
-
- function showAuthError()
- {
- header('HTTP/1.1 401 Unauthorized');
- $msg = 'Could not authenticate you.';
-
- if ($this->format == 'xml') {
- header('Content-Type: application/xml; charset=utf-8');
- $this->startXML();
- $this->elementStart('hash');
- $this->element('error', null, $msg);
- $this->element('request', null, $_SERVER['REQUEST_URI']);
- $this->elementEnd('hash');
- $this->endXML();
- } elseif ($this->format == 'json') {
- header('Content-Type: application/json; charset=utf-8');
- $error_array = array('error' => $msg,
- 'request' => $_SERVER['REQUEST_URI']);
- print(json_encode($error_array));
- } else {
- header('Content-type: text/plain');
- print "$msg\n";
- }
- }
-
}