Dougy Mak's Blog

MY BLOG!

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

No comments yet. Be the first.

Leave a reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

L:) ;) :| :x :twisted: :roll: :oops: :o :mrgreen: :lol: :idea: :evil: :cry: :arrow: :P :D :?: :? :) :( :!: 8O 8)