diff options
author | James Walker <walkah@walkah.net> | 2010-07-27 12:18:40 -0400 |
---|---|---|
committer | James Walker <walkah@walkah.net> | 2010-07-27 12:18:40 -0400 |
commit | 772018810b7b6ea2b8cf18a1b9275fbac8c78343 (patch) | |
tree | df788d098e5f982322c36d7c2954ac41f9b21fda /lib/apiauth.php | |
parent | 7065450f03078fb1ac2105b75f9c7a4e052bca9c (diff) | |
parent | 65862d8f7f45d487d4714137af96d3a24e4ca386 (diff) |
Merge branch 'master' into testing
Diffstat (limited to 'lib/apiauth.php')
-rw-r--r-- | lib/apiauth.php | 38 |
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"; - } - } - } |