Yes, you are totally right. The error is because authenticate() method may (and according to the experienced problems does) return NULL.
Marco, you are checking for exception's message and return Zend_Auth_Result only in case if it's Model_User::WRONG_PW or Model_User::NOT_FOUND, so if something went wrong and another exception was thrown your authenticate() method will return NULL. Here's fixed version just in case to show the place of error (I'm sorry I have formatted it the way I like): http://gist.github.com/473653 2010/7/13 Mon Zafra <[email protected]>: > My guess is that Model_User::authenticate() throws an exception that is not > handled by the two if's in the catch block (i.e. $e->getMessage() is neither > NOT_FOUND nor WRONG_PW). I'd suggest you add a "throw $e;" after the second > if block inside the catch to see exactly what the model threw. Would also > help if we could see the Model_User class. > > -- Mon > > > On Mon, Jul 12, 2010 at 8:54 PM, MrMastermindNL <[email protected]> > wrote: >> >> Thanks for your reply Mon, here's my adapter class, maybe you can tell me >> what is missing here: >> >> class RS_Auth_Adapter implements Zend_Auth_Adapter_Interface >> { >> const NOT_FOUND_MSG = 'Account not found'; >> const BAD_PW_MSG = 'Password in invalid'; >> >> protected $user = null; >> protected $username = ''; >> protected $password = ''; >> >> public function __construct($username, $password) >> { >> $this->username = $username; >> $this->password = $password; >> } >> >> /** >> * @throws Zend_Auth_Adapter_Exception >> * @returns Zend_Auth_Result >> */ >> >> public function authenticate() >> { >> try >> { >> $this->user = Model_User::authenticate($this->username, >> $this->password); >> return $this->createResult(Zend_Auth_Result::SUCCESS); >> } >> catch(Exception $e) >> { >> if($e->getMessage() == Model_User::WRONG_PW) >> return >> $this->createResult(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, >> array(self::BAD_PW_MSG)); >> >> if($e->getMessage() == Model_User::NOT_FOUND) >> return >> $this->createResult(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, >> array(self::NOT_FOUND_MSG)); >> } >> } >> >> private function createResult($code, $messages = array()) >> { >> return new Zend_Auth_Result($code, $this->user, $messages); >> } >> } >> -- >> View this message in context: >> http://zend-framework-community.634137.n4.nabble.com/Zend-Auth-session-expired-fatal-error-tp2225703p2286085.html >> Sent from the Zend Framework mailing list archive at Nabble.com. > > -- Sincerely yours, Aleksey V. Zapparov A.K.A. ixti FSF Member #7118 Mobile Phone: +34 617 179 344 Homepage: http://www.ixti.ru JID: [email protected] *Origin: Happy Hacking!
