From 743c844084bae75db02570d76694f4e9b79a9aa9 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 9 Oct 2009 16:57:22 -0700 Subject: Move all basic auth output and processing to base classes --- lib/apiauth.php | 24 ++++++++++++++++++++++-- lib/apibareauth.php | 16 ++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/apiauth.php b/lib/apiauth.php index d7f8017eb..9fc0e5712 100644 --- a/lib/apiauth.php +++ b/lib/apiauth.php @@ -48,6 +48,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? * @@ -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? * -- cgit v1.2.3-54-g00ecf