diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-03-28 03:42:39 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-03-28 03:42:40 +0400 |
commit | ae4b03163792f0b6e933933e5d37df87dc3fd566 (patch) | |
tree | d1d7510a9728f587d3d63ebd03e4ecf3d904838b /plugins/Login/Auth.php | |
parent | 158c2150f5f2e13ece459b8d131244c11b763997 (diff) |
Mass conversion of all files to the newly agreed coding standard: PSR 1/2
Converting Piwik core source files, PHP, JS, TPL, CSS
More info: http://piwik.org/participate/coding-standards/
Diffstat (limited to 'plugins/Login/Auth.php')
-rw-r--r-- | plugins/Login/Auth.php | 177 |
1 files changed, 86 insertions, 91 deletions
diff --git a/plugins/Login/Auth.php b/plugins/Login/Auth.php index c8c58e7aaf..a7a8a2e490 100644 --- a/plugins/Login/Auth.php +++ b/plugins/Login/Auth.php @@ -15,106 +15,101 @@ */ class Piwik_Login_Auth implements Piwik_Auth { - protected $login = null; - protected $token_auth = null; + protected $login = null; + protected $token_auth = null; - /** - * Authentication module's name, e.g., "Login" - * - * @return string - */ - public function getName() - { - return 'Login'; - } + /** + * Authentication module's name, e.g., "Login" + * + * @return string + */ + public function getName() + { + return 'Login'; + } - /** - * Authenticates user - * - * @return Piwik_Auth_Result - */ - public function authenticate() - { - $rootLogin = Piwik_Config::getInstance()->superuser['login']; - $rootPassword = Piwik_Config::getInstance()->superuser['password']; - $rootToken = Piwik_UsersManager_API::getInstance()->getTokenAuth($rootLogin, $rootPassword); + /** + * Authenticates user + * + * @return Piwik_Auth_Result + */ + public function authenticate() + { + $rootLogin = Piwik_Config::getInstance()->superuser['login']; + $rootPassword = Piwik_Config::getInstance()->superuser['password']; + $rootToken = Piwik_UsersManager_API::getInstance()->getTokenAuth($rootLogin, $rootPassword); - if(is_null($this->login)) - { - if($this->token_auth === $rootToken) - { - return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, $this->token_auth ); - } + if (is_null($this->login)) { + if ($this->token_auth === $rootToken) { + return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, $this->token_auth); + } - $login = Piwik_FetchOne( - 'SELECT login - FROM '.Piwik_Common::prefixTable('user').' + $login = Piwik_FetchOne( + 'SELECT login + FROM ' . Piwik_Common::prefixTable('user') . ' WHERE token_auth = ?', - array($this->token_auth) - ); - if(!empty($login)) - { - return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS, $login, $this->token_auth ); - } - } - else if(!empty($this->login)) - { - if($this->login === $rootLogin - && ($this->getHashTokenAuth($rootLogin, $rootToken) === $this->token_auth) - || $rootToken === $this->token_auth) - { - $this->setTokenAuth($rootToken); - return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, $this->token_auth ); - } + array($this->token_auth) + ); + if (!empty($login)) { + return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS, $login, $this->token_auth); + } + } else if (!empty($this->login)) { + if ($this->login === $rootLogin + && ($this->getHashTokenAuth($rootLogin, $rootToken) === $this->token_auth) + || $rootToken === $this->token_auth + ) { + $this->setTokenAuth($rootToken); + return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, $this->token_auth); + } - $login = $this->login; - $userToken = Piwik_FetchOne( - 'SELECT token_auth - FROM '.Piwik_Common::prefixTable('user').' + $login = $this->login; + $userToken = Piwik_FetchOne( + 'SELECT token_auth + FROM ' . Piwik_Common::prefixTable('user') . ' WHERE login = ?', - array($login) - ); - if(!empty($userToken) - && (($this->getHashTokenAuth($login, $userToken) === $this->token_auth) - || $userToken === $this->token_auth)) - { - $this->setTokenAuth($userToken); - return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS, $login, $userToken ); - } - } + array($login) + ); + if (!empty($userToken) + && (($this->getHashTokenAuth($login, $userToken) === $this->token_auth) + || $userToken === $this->token_auth) + ) { + $this->setTokenAuth($userToken); + return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS, $login, $userToken); + } + } - return new Piwik_Auth_Result( Piwik_Auth_Result::FAILURE, $this->login, $this->token_auth ); - } + return new Piwik_Auth_Result(Piwik_Auth_Result::FAILURE, $this->login, $this->token_auth); + } - /** - * Accessor to set login name - * - * @param string $login user login - */ - public function setLogin($login) - { - $this->login = $login; - } + /** + * Accessor to set login name + * + * @param string $login user login + */ + public function setLogin($login) + { + $this->login = $login; + } - /** - * Accessor to set authentication token - * - * @param string $token_auth authentication token - */ - public function setTokenAuth($token_auth) - { - $this->token_auth = $token_auth; - } + /** + * Accessor to set authentication token + * + * @param string $token_auth authentication token + */ + public function setTokenAuth($token_auth) + { + $this->token_auth = $token_auth; + } - /** - * Accessor to compute the hashed authentication token - * - * @param string $login user login - * @param string $token_auth authentication token - * @return string hashed authentication token - */ - public function getHashTokenAuth($login, $token_auth) - { - return md5($login . $token_auth); - } + /** + * Accessor to compute the hashed authentication token + * + * @param string $login user login + * @param string $token_auth authentication token + * @return string hashed authentication token + */ + public function getHashTokenAuth($login, $token_auth) + { + return md5($login . $token_auth); + } } |