I'm struggling with the concept of creating an admin section in CakePHP-project. (version 2.3.5)
I have uncommented the line in Config/core.php:
Configure::write('Routing.prefixes', array('admin'));
I have added the line in Config/routes.php: (Just as they advice to do in CakePHP cookbook.)
Router::connect('/admin', array('controller'=>'pages', 'action'=>'index','admin' => true));
In AppController.php I have the following:
public $components = array(
'Session',
'Auth' => array(
'loginRedirect'=>array('controller'=>'pages','action'=>'index', 'admin'=>true),
'logoutRedirect'=>array('controller'=>'pages','action'=>'display','home'),
'authError'=>'you have no access.',
'authorize'=>array('Controller')
)
);
Then I have added a layout View/Pages/admin_index.ctp which is where I want to be redirected after login. I managed to get my login working in UsersController.php.
So the question is, where should I redirect in AppController.php to get my logged admin to the admin_view? I believe that loginRedirect is somehow broken..
I have studied some tutorials on this subject but I have found only this Youtube-video http://www.youtube.com/watch?v=zvwQGZ1BxdM All other tutorials seem to be concerning earlier versions of CakePHP.
I guess you could set a loginAction in AppController and then inside this action you could do:
$this->redirect(array('controller'=>'someController','action'=>'someAction','admin'=>true));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With