summaryrefslogtreecommitdiff
path: root/actions/api.php
diff options
context:
space:
mode:
Diffstat (limited to 'actions/api.php')
-rw-r--r--actions/api.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/actions/api.php b/actions/api.php
index a52570320..69fda2e22 100644
--- a/actions/api.php
+++ b/actions/api.php
@@ -45,9 +45,7 @@ class ApiAction extends Action {
$this->api_method = $cmdext[0];
$this->content_type = strtolower($cmdext[1]);
}
-
- # common_debug("apiaction = $this->api_action, method = $this->api_method, argument = $this->api_arg, ctype = $this->content_type");
-
+
# XXX Maybe check to see if the command actually exists first?
if($this->requires_auth()) {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
@@ -56,7 +54,7 @@ class ApiAction extends Action {
header('WWW-Authenticate: Basic realm="Laconica API"');
# if the user hits cancel -- bam!
- common_show_basic_auth_error();
+ $this->show_basic_auth_error();
} else {
$nickname = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
@@ -67,7 +65,7 @@ class ApiAction extends Action {
$this->process_command();
} else {
# basic authentication failed
- common_show_basic_auth_error();
+ $this->show_basic_auth_error();
}
}
} else {
@@ -123,5 +121,12 @@ class ApiAction extends Action {
return true;
}
}
+
+ function show_basic_auth_error() {
+ header('HTTP/1.1 401 Unauthorized');
+ header('Content-type: text/plain');
+ print("Could not authenticate you."); # exactly what Twitter says - no \n
+ exit();
+ }
}