currently, to login a user in Zend Framework, i do something like
public function loginAction()
{
if ($this->getRequest()->isPost()) {
$adapter = new Application_Auth_Adapter(
$this->getRequest()->getParam('username'),
$this->getRequest()->getParam('password')
);
$auth = Zend_Auth::getInstance();
$auth->authenticate($adapter);
if ($auth->hasIdentity()) {
echo $auth->getIdentity()->name;
} else {
echo "failed login";
}
} else {
echo "not posted";
}
}
but i am wondering if i shld have all the validation logic
$auth = Zend_Auth::getInstance();
$auth->authenticate($adapter);
if ($auth->hasIdentity()) { ...
put inside a Zend_Validate
instead then all my controller does is check if the form isValid()
? most tutorials do the authentication in controllers but i am wondering since authenticating a user login sounds like validation to me ...