problem wygląda następująco: (sorry za całe kawałki kodu ale zależy mi aby ktoś rzucił swoim okiem i stwierdził w jakim stopniu jest to bezpieczne).
- mam formularz do logowania - wygląda o tak:
public function init() { $this->setMethod('post'); $view = Zend_Layout::getMvcInstance()->getView(); 'controller' => 'index', 'action' => 'login' )); $this->setAction($url); $this->addElement('submit', 'submit', array('label' => '', 'id' => 'submit_login', 'ignore' => true)); 'class' => 'login_aside_form' )); 'FormElements', )); $this->username->clearDecorators(); $this->password->clearDecorators(); $this->setElementDecorators( 'ViewHelper', 'Errors', ) ); }
dalej mam akcję odpowiedzialną za formularz: (dorobić muszę tutaj jeszcze jakieś sha1() dla hasła)
Zend_Db_Table_Abstract::setDefaultAdapter('db1'); $this->_helper->viewRenderer('index'); $form = new Application_Form_Login(); if ($form->isValid($this->getRequest()->getPost())) { $adapter = new Zend_Auth_Adapter_DbTable( null, 'user', 'username', 'password' ); $adapter->setIdentity($form->getValue('username')); $adapter->setCredential($form->getValue('password')); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if ($result->isValid()) { return $this->_helper->redirector( 'index', 'index', 'default' ); } $form->password->addError('Błędna próba logowania!'); } $this->view->formLogin = $form;
sam formularz wyświetlam w taki sposób:
<?php //<input type="text" id="password-clear" value="Hasło:"> ?> <div class="login_links"> <a href="#" id="register_link_aside" title="Zarejestruj się">Zarejestruj się</a> <a href="#" id="password_link_aside" title="Przypomnij hasło">Przypomnij hasło</a> </div><!-- end .login_links --> </form>
i teraz mam taki problem, że formularz jest wyświetlany w głównym widoku layout.phtml i w czasie sprawdzania czy np. pole formularza nie jest puste, przenosi użytkownika do akcji index/login, a chciałbym aby cały czas pozostawał on w index/index.
Problem nie występuje jak się user poprawnie zaloguje, wtedy zrobiłem coś takiego:
if ($result->isValid()) { return $this->_helper->redirector( 'index', 'index', 'default' ); }
i user trafia do index/index
niby akcja index/login korzysta z widoku index
ale to nie eliminuje mi problemu.. co tu można zmienić?
$this->_helper->viewRenderer('index');