Dougy Mak's Blog

MY BLOG!

Archive for the 'Zend Framework Stuff' Category

Getting control over authentication results

So, to get control over the authentication results for various errors such as no such username, wrong password, etc..  You can use this:

$result = $this->_auth->authenticate($adapter);
switch ($result->getCode()) {
case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
/** do stuff for nonexistent identity **/
break;
case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
/** do stuff for invalid credential **/
break;
case Zend_Auth_Result::SUCCESS:
/** do stuff for successful authentication **/
break;
default:
/** do stuff for other failure **/
break;
}

$result = $this->_auth->authenticate($adapter);

switch ($result->getCode()) {

case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:

/** do stuff for nonexistent identity **/

break;

case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:

/** do stuff for invalid credential **/

break;

case Zend_Auth_Result::SUCCESS:

/** do stuff for successful authentication **/

break;

default:

/** do stuff for other failure **/

break;

}

http://framework.zend.com/manual/en/zend.auth.introduction.html#zend.auth.introduction.results

No comments

Zend_Auth returns results and identity

This actually help me realized that my login wasn’t logging in properly to begin with. I needed to check if a person was logged on or not, and I found out you can see if the visitor has an identity and you can even get it with the following commands:

Zend_Auth::getInstance()->getIdentity()

Zend_Auth::getInstance()->hasIdentity()

More information here:
http://framework.zend.com/manual/en/zend.auth.introduction.html

No comments

Show your stack trace

I kept getting the following error:

An error occurred
Application error

And that means nothing to me. I don’t know what is going on, so I found out you can set the following in your .htaccess under your public folder and then you will be able to see the stack trace which gives you a better idea of what is wrong.

SetEnv APPLICATION_ENV “development”

No comments