代码之家  ›  专栏  ›  技术社区  ›  Sonny

具有两个标识列的Zend身份验证

  •  1
  • Sonny  · 技术社区  · 15 年前

    我正在使用 Zend_Auth 验证用户凭据并遇到问题。我需要双重身份。这两列分别是用户名和客户标识符。这个 identityColumn 设置和 setIdentity() 方法不允许此方案。我试图通过使用 credentialTreatment 设置,但当我为两个或多个客户使用重复的用户名时,它只计算 zend_auth_credential_match 对于其他客户来说是错误的,而不是过滤掉那些用户。

    这里有一个 消毒的 zend auth执行的结果查询示例:

    SELECT `users`.*,
        (CASE
            WHEN `password` = 'password'
                AND active = 1
                AND customer_id = 1
                THEN 1 
            ELSE 0
            END) AS `zend_auth_credential_match`
    FROM `users`
    WHERE (`username` = 'username')
    

    有必要延长 登达奥特 要执行此操作的模块?有没有其他人做过并且可以提供一个例子?

    谢谢!

    2 回复  |  直到 15 年前
        1
  •  5
  •   gnarf    15 年前

    Zend_Auth_Adapter_DbTable

    class My_Auth_Adapter extends Zend_Auth_Adapter_DbTable {
      protected $_customerColumn = 'customer_id';
      protected $_customerId = false;
    
      public function setCustomerId($id) {
        $this->_customerId = $id;
        return $this;
      }
    
      public function getCustomerId() {
        return $this->_customerId!==false?$this->_customerId:'';
      }
    
      public function _authenticateCreateSelect() {
        $select = parent::_authenticateCreateSelect();
        $select->where($this->_zendDb->quoteIdentifier($this->_customerColumn, true)." = ?", $this->getCustomerId());
        return $select;
      }
    }
    
        2
  •  3
  •   prodigitalson    15 年前

    推荐文章