ZfcUser Authenticate and redirect

For programming and general questions on Zend Framework
Post Reply
bartreis
Posts: 1
Joined: Tue Jan 08, 2013 4:07 pm

ZfcUser Authenticate and redirect

Post by bartreis » Tue Jan 08, 2013 4:18 pm

Hi guys,
i am trying to protect my pages using zfcUser in ZF2,
but when i try to redirect the page to 'user' page, where he will need to login, but i got an error:

Code: Select all

if(!$this->zfcUserIdentity()){
	//it enters here
	return $this->redirect()->toRoute('album');//Error line
}
I am using it in a .phtml page, if it is wrong to put here, where is the most correct place to put it ?
and if it is not the correct way to protect a page with a non-logged user, what is the best way?

Error Log:

Code: Select all

[Thu Jan 03 14:55:10 2013] [error] [client 192.168.0.5] PHP Fatal error:  Uncaught exception 'Zend\\ServiceManager\\Exception\\ServiceNotFoundException' with message 'Zend\\ServiceManager\\ServiceManager::get was unable to fetch or create an instance for redirect' in /var/www/kennel/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:452\nStack trace:\n#0 /var/www/kennel/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/ServiceManager/AbstractPluginManager.php(110): Zend\\ServiceManager\\ServiceManager->get('redirect', true)\n#1 /var/www/kennel/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/View/Renderer/PhpRenderer.php(340): Zend\\ServiceManager\\AbstractPluginManager->get('redirect', NULL)\n#2 /var/www/kennel/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/View/Renderer/PhpRenderer.php(359): Zend\\View\\Renderer\\PhpRenderer->plugin('redirect')\n#3 /var/www/kennel/ZendSkeletonApplication/module/Album/view/album/album/edit.phtml(8): Zend\\View\\Renderer\\PhpRenderer->__call('re in /var/www/kennel/ZendSkeletonApplication/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 452

Post Reply