簡體   English   中英

Zend中authenticate()操作的問題

[英]Issues with the authenticate() action in Zend

我正在將Netbeans 8.0與Xampp 3.2.1一起使用,並且收到一條錯誤消息“ Aplication error”,我已經發現了問題所在,如您在代碼段中所示:

public function loginAction() {

    $users = new Application_Model_DbTable_User();
    $form = new Application_Form_Login();
    $this->view->form = $form;
    if ($this->getRequest()->isPost()) {
        if ($form->isValid($_POST)) {
            $data = $form->getValues();
            $auth = Zend_Auth::getInstance();
            $authAdapter = new Zend_Auth_Adapter_DbTable($users->getAdapter(), 'users');
            $authAdapter->setIdentityColumn('username')->setCredential('password');
            $authAdapter->setIdentity($data['username'])->setCredential($data['password']);

            $result = $auth->authenticate($authAdapter); // <- The problem is here
            $dump = $result->getCode();
            var_dump($dump);
            die;

            if ($result->isValid()) {
                $storage = new Zend_Auth_Storage_Session();
                $storage->write($authAdapter->getResultRowObject());
                $this->_redirect('Authentification/login');
            } else {
                $this->view->errorMessage = "Invalid username or password!";
            }
        }
    }
}

我是Zend的新手,無法真正解決該問題,有沒有比var_dump更好的解決方法? 我嘗試過xdebug,但無法使其在我的項目中正常工作。

首先,您必須通過config / application.ini打開顯示錯誤

在[生產]和[開發:生產]階段中檢查這三行是否必須設置為1:

phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

因此,您會收到有關異常或任何其他錯誤的正確錯誤消息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM