summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2009-10-09 16:57:22 -0700
committerZach Copley <zach@status.net>2009-10-09 16:57:22 -0700
commit743c844084bae75db02570d76694f4e9b79a9aa9 (patch)
treeb1a4254c092a10777aec3688024dd2d48f9916b9 /lib
parentf746993c2bfb674d397cf095a2ab2ff7e757818b (diff)
Move all basic auth output and processing to base classes
Diffstat (limited to 'lib')
-rw-r--r--lib/apiauth.php24
-rw-r--r--lib/apibareauth.php16
2 files changed, 38 insertions, 2 deletions
diff --git a/lib/apiauth.php b/lib/apiauth.php
index d7f8017eb..9fc0e5712 100644
--- a/lib/apiauth.php
+++ b/lib/apiauth.php
@@ -49,6 +49,26 @@ class ApiAuthAction extends ApiAction
var $auth_user = null;
/**
+ * Take arguments for running, and output basic auth header if needed
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ if ($this->requiresAuth()) {
+ $this->checkBasicAuthUser();
+ }
+
+ return true;
+ }
+
+ /**
* Does this API resource require authentication?
*
* @return boolean true
@@ -76,7 +96,7 @@ class ApiAuthAction extends ApiAction
// show error if the user clicks 'cancel'
$this->showBasicAuthError();
- return false;
+ exit;
} else {
$nickname = $this->auth_user;
@@ -94,7 +114,7 @@ class ApiAuthAction extends ApiAction
"$nickname, proxy = $proxy, ip = $ip."
);
$this->showBasicAuthError();
- return false;
+ exit;
}
}
return true;
diff --git a/lib/apibareauth.php b/lib/apibareauth.php
index a99d450ec..0ae477f46 100644
--- a/lib/apibareauth.php
+++ b/lib/apibareauth.php
@@ -48,6 +48,22 @@ require_once INSTALLDIR.'/lib/apiauth.php';
class ApiBareAuthAction extends ApiAuthAction
{
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ return true;
+ }
+
/**
* Does this API resource require authentication?
*