diff options
author | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-09-25 14:57:22 +0400 |
---|---|---|
committer | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-09-25 14:57:22 +0400 |
commit | bd41f1ae0122cd0ae6eb44633e5cd835c000ef18 (patch) | |
tree | d6e58b805ec05ae90b43bc36208eadc75dd179d7 | |
parent | e08998fbf9a99b8ab57fcc4728dad986374b7ec1 (diff) |
Remove use of Zend_Auth_Result.
-rw-r--r-- | core/Access.php | 2 | ||||
-rw-r--r-- | core/Auth.php | 72 | ||||
-rw-r--r-- | plugins/Login/Auth.php | 2 |
3 files changed, 59 insertions, 17 deletions
diff --git a/core/Access.php b/core/Access.php index 303e5d638d..6e13db6579 100644 --- a/core/Access.php +++ b/core/Access.php @@ -162,7 +162,7 @@ class Access // access = array ( idsite => accessIdSite, idsite2 => accessIdSite2) $result = $this->auth->authenticate(); - if (!$result->isValid()) { + if (!$result->wasAuthenticationSuccessful()) { return false; } $this->login = $result->getIdentity(); diff --git a/core/Auth.php b/core/Auth.php index 67edbbabaf..30401d0e04 100644 --- a/core/Auth.php +++ b/core/Auth.php @@ -39,35 +39,57 @@ interface Auth * * @package Piwik * @subpackage Piwik_Auth - * @see Zend_AuthResult, libs/Zend/Auth/Result.php - * @link http://framework.zend.com/manual/en/zend.auth.html */ -class AuthResult extends \Zend_Auth_Result +class AuthResult { + const FAILURE = 0; + const SUCCESS = 1; + const SUCCESS_SUPERUSER_AUTH_CODE = 42; + /** * token_auth parameter used to authenticate in the API * * @var string */ - protected $_token_auth = null; + protected $tokenAuth = null; - const SUCCESS_SUPERUSER_AUTH_CODE = 42; + /** + * The login used to authenticate. + * + * @var string + */ + protected $login = null; + + /** + * The authentication result code. Can be self::FAILURE, self::SUCCESS, or + * self::SUCCESS_SUPERUSER_AUTH_CODE. + * + * @var int + */ + protected $code = null; /** * Constructor for AuthResult * * @param int $code * @param string $login identity - * @param string $token_auth - * @param array $messages + * @param string $tokenAuth + */ + public function __construct($code, $login, $tokenAuth) + { + $this->code = (int)$code; + $this->login = $login; + $this->tokenAuth = $tokenAuth; + } + + /** + * Returns the login used to authenticate. + * + * @return string */ - public function __construct($code, $login, $token_auth, array $messages = array()) + public function getIdentity() { - // AuthResult::SUCCESS_SUPERUSER_AUTH_CODE, AuthResult::SUCCESS, AuthResult::FAILURE - $this->_code = (int)$code; - $this->_identity = $login; - $this->_messages = $messages; - $this->_token_auth = $token_auth; + return $this->login; } /** @@ -77,6 +99,26 @@ class AuthResult extends \Zend_Auth_Result */ public function getTokenAuth() { - return $this->_token_auth; + return $this->tokenAuth; } -} + + /** + * Returns the authentication result code. + * + * @return int + */ + public function getCode() + { + return $this->code; + } + + /** + * Returns true if this result was successfully authentication. + * + * @return bool + */ + public function wasAuthenticationSuccessful() + { + return $this->code > self::FAILURE; + } +}
\ No newline at end of file diff --git a/plugins/Login/Auth.php b/plugins/Login/Auth.php index 10bad0d0ac..c60ea2d635 100644 --- a/plugins/Login/Auth.php +++ b/plugins/Login/Auth.php @@ -119,4 +119,4 @@ class Auth implements \Piwik\Auth { return md5($login . $token_auth); } -} +}
\ No newline at end of file |