2012-09-13 32 views
1

我的Zend_Auth函數有問題。Zend會話使用失敗登錄擦除

我有一個網絡應用程序,當Zend_Auth會話中的密鑰超時時提示用戶使用登錄框。當用戶使用正確的憑證登錄時,會話中的密鑰重置爲true。但是,當用戶輸入錯誤的憑證時,會話中的所有密鑰都將被擦除,並且會話的有效期更長?

我在想,如果Zend_Auth::getInstance()函數是擦拭它開始新鮮?

任何想法?

protected function _process($values) 
{ 
    // grab data from config 
    $iniTime = Zend_Registry::get('config')->inactive->session; 
    $expireTime = $iniTime->timeout; 
    $realIP = new Application_Model_RealIP(); 
    // Get our authentication adapter and check credentials 
    $adapter = $this->_getAuthAdapter(); 
    $adapter->setIdentity($values['email']); 
    //$pwEncode->encode_password($values['password']) 
    $adapter->setCredential($values['password']); 
    $auth = Zend_Auth::getInstance(); 
    $result = $auth->authenticate($adapter); 
    if ($result->isValid()) { 
     $user = $adapter->getResultRowObject(); 
     $user->session_IP = $realIP->getRealIpAddr(); 
     $auth->getStorage()->write($user); 
     //check whether the client is authenticated 
     $session = new Zend_Session_Namespace('new_session'); 
     // Set "dummy" key with expiration 
     $session->key = true; 
     $session->setExpirationSeconds($expireTime, 'key'); 
     return true; 
    } 
    return false; 
} 

鏈接調用_process方法link

+0

如果身份驗證失敗,您的authAdapter會執行什麼操作,因爲在您的_process()函數中,您只是返回false,或者如果_process()返回FALSE,您的登錄控制器會執行什麼操作? – RockyFord

+0

嘿,感謝您的快速回復,這裏是調用_process方法的功能 [link](http://paste.laravel.com/5wQ) 它應該只是記錄一個審計事件併發回一個json給用戶的消息給出錯誤信息。 – Perceptive

回答

0

從我可以告訴你需要_forward()保留請求)或_redirect()新的請求)的身份驗證功能回到登錄,這可能是因爲_process()中的authenticate()失敗或authAction()中的第60和100行之間的某處。

從我一直在閱讀它似乎登錄失敗登錄和數據庫更新,但然後......什麼都沒有。沒有重定向,沒有轉發,只有一個標題設置爲500,並生成一條消息。

希望這會有所幫助。我希望我完全不會錯過它。

+0

哦,我明白了,當_redirect被使用時,新的會話被製作爲只是_forward()? – Perceptive