开发者

_forward() in Zend does not work?

Here is a code:

    public function loginAction()
{
    $form = new Application_Form_Login();
    $this->view->form = $form;

    if($this->_request->isPost())
    {
        self::$dataForm = $this->_request->getPost();
        if($this->form->isValid(self::$dataForm))
        {
            return $this->_forward('authorization');
        } else
        {
            $this->form->populate(self::$form);
        }
    }

}

public function authorizationAction()
{
    if($this->_request->isPost())
    {
        $auth = Zend_Auth::getInstance();
        $authAdapter = new Application_Model_User($this->user->getAdapter(),'user');
        $authAdapter->setId开发者_如何学JAVAentityColumn('USERNAME')
                    ->setCredentialColumn('PASSWORD');
        $password = md5(self::$dataForm['password']);
        $authAdapter->setIdentity(self::$dataForm['username']);
        $authAdapter->setCredental($password);

        $result = $auth->authenticate($authAdapter);
        echo 'ok';
        /*
        if($result->isValid())
        {
            //$this->_forward('authorized', 'user');
            echo 'ok';
        }*/
    }
}

Any idea why it does not work? I didn't get any error just blank page.


Shouldn't you be calling if($form->isValid(self::$dataForm)) ?


As far as I understand it is a bad idea to use the $this->_forward() as it calls the dispatch loop again.

Personally I would place the authorization code into a model class and pass it the username & password from the form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜