开发者

Redirect to dashboard by user's group

开发者 https://www.devze.com 2023-03-27 14:30 出处:网络
I have acl based CakePHP app and users are belong to groups. Please开发者_如何学C advice me where I should implement the redirection code by user\'s group:

I have acl based CakePHP app and users are belong to groups.

Please开发者_如何学C advice me where I should implement the redirection code by user's group:

  • users belong to admin group redirect to admin/dashboard
  • users belong to manager group redirect to manager/dashboard
  • users belong to user group redirect to user/dashboard


set $this->Auth->autoRedirect = false; in beforeRedirect() in users controller

In the login() function:

if ($this->Auth->user()){
$this->redirect(array('prefix'=>$this->Auth->user('group'),'controller'=>'dashboard','action'=>'index'));
 }

This code is just example to show how it is done, not to be taken as-is.

0

精彩评论

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

关注公众号