Skip to content
Extraits de code Groupes Projets
Valider bd41f1ae rédigé par Benaka Moorthi's avatar Benaka Moorthi
Parcourir les fichiers

Remove use of Zend_Auth_Result.

parent e08998fb
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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();
......
......@@ -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
......@@ -119,4 +119,4 @@ class Auth implements \Piwik\Auth
{
return md5($login . $token_auth);
}
}
}
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter