1
目前,登陸在Zend框架用戶,我這樣做在Zend_Validate而不是控制器操作中執行認證認證?
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";
}
}
,但我想知道如果我SHLD都驗證邏輯把Zend_Validate
不是那麼所有內部
$auth = Zend_Auth::getInstance();
$auth->authenticate($adapter);
if ($auth->hasIdentity()) { ...
我控制器做的是檢查表格是否爲isValid()
?大多數教程做控制器的驗證,但我想知道,因爲驗證用戶登錄聽起來像是驗證我...