Piwik\Plugins\Login\SessionInitializer::getHashTokenAuth PHP Method

getHashTokenAuth() public static method

Accessor to compute the hashed authentication token.
public static getHashTokenAuth ( string $login, string $token_auth ) : string
$login string user login
$token_auth string authentication token
return string hashed authentication token
    public static function getHashTokenAuth($login, $token_auth)
    {
        return md5($login . $token_auth);
    }

Usage Example

Example #1
0
 /**
  * Authenticates user
  *
  * @return AuthResult
  */
 public function authenticate()
 {
     if (!empty($this->md5Password)) {
         // favor authenticating by password
         $this->token_auth = UsersManagerAPI::getInstance()->getTokenAuth($this->login, $this->getTokenAuthSecret());
     }
     if (is_null($this->login)) {
         $model = new Model();
         $user = $model->getUserByTokenAuth($this->token_auth);
         if (!empty($user['login'])) {
             $code = $user['superuser_access'] ? AuthResult::SUCCESS_SUPERUSER_AUTH_CODE : AuthResult::SUCCESS;
             return new AuthResult($code, $user['login'], $this->token_auth);
         }
     } else {
         if (!empty($this->login)) {
             $model = new Model();
             $user = $model->getUser($this->login);
             if (!empty($user['token_auth']) && (SessionInitializer::getHashTokenAuth($this->login, $user['token_auth']) === $this->token_auth || $user['token_auth'] === $this->token_auth)) {
                 $this->setTokenAuth($user['token_auth']);
                 $code = !empty($user['superuser_access']) ? AuthResult::SUCCESS_SUPERUSER_AUTH_CODE : AuthResult::SUCCESS;
                 return new AuthResult($code, $this->login, $user['token_auth']);
             }
         }
     }
     return new AuthResult(AuthResult::FAILURE, $this->login, $this->token_auth);
 }
All Usage Examples Of Piwik\Plugins\Login\SessionInitializer::getHashTokenAuth