/** * 認証処理を行う。 * * @param integer $id ユーザーID * @param string $password パスワード * @param boolean $isHash パスワードがハッシュかどうか * * @return boolean 認証成功ならtrue、失敗ならfalse */ public function authentication($id = null, $password = null, $isHash = false) { // カレントユーザーが認証済みか? if (!$this->_authOBJ->hasIdentity()) { if (!$id or !$password) { return FALSE; } if ($isHash) { $passwordKey = $password; } else { $passwordKey = AdmAdmin::createPasswordKey($password); } $adapter = new ComAuthAdapterDbTable($this->getDbObject(), "admin", "login_id", "password"); $adapter->setIdentity($id)->setCredential($passwordKey); $select = $adapter->getDbSelect(); $select->where("disable = 0"); $select->limit(1); // 認証処理を実行 $result = $this->_authOBJ->authenticate($adapter); if (!$result->isValid()) { return FALSE; } else { // 必要な情報をセッションに登録 $this->_authOBJ->getStorage()->write($adapter->getResultRowObject(NULL, array("password", "disable"))); return TRUE; } // 認証済み } else { return TRUE; } }