Дамы и господа,
Я усердно работаю над новым веб-приложением, основанным на Zend Framework.
Почти все веб-приложение будет защищено логином (именем пользователя и паролем).
Моя идея - проверить, может ли посетитель пройти аутентификацию, и если нет, проверить, запрашивает ли пользователь маршрут входа. Если он не пытается войти, он будет перенаправлен на страницу входа.
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Bootstrap::_initRouterRewrites()
*
* @return void
*/
protected function _initRouterRewrites()
{
$frontController = Zend_Controller_Front::getInstance();
$this->router = $frontController->getRouter();
$this->router->addRoute(
'default',
new Zend_Controller_Router_Route('/',
array('controller' => 'index',
'action' => 'index'))
)
->addRoute(
'login',
new Zend_Controller_Router_Route('/inloggen.html',
array('controller' => 'auth',
'action' => 'login'))
);
}
/**
* Bootstrap::_initZendSession()
*
* @return void
*/
protected function _initZendSession()
{
// Ensure that both the session and the db resources are bootstrapped
$this->bootstrap(array('db', 'session'));
// Actually start the session
Zend_Session::start();
}
/**
* Bootstrap::_initAuthentication()
*
* @return void
*/
protected function _initAuthentication()
{
// Instantiate auth object
$auth = Zend_Auth::getInstance();
// Check if visitor has an identity
if (!$auth->hasIdentity())
{
}
}
}
Когда я использую метод $ this-> router-> getCurrrentRoute () в методе _initAuthentication, я получаю следующую ошибку: «Текущий маршрут не определен».
Что я могу сделать, чтобы проверить, является ли текущий маршрут логином?
Заранее спасибо!