Try this hopely it can help 

public function login() {
      if ($this->request->is('post')) {
                $user = $this->Auth->identify();
                if ($user) {
                    $this->Auth->setUser($user);
                  *  $userrole = $this->request->session()*
*                            ->read('Auth.User.role');*
                *    if ($userrole == 'admin') {*
*                        return $this->redirect(['controller' => 'Admin', 
'action' => 'someaction']);*
*                    } else {*
*                        return $this->redirect(['controller' => 'User', 
'action' => 'someaction']);*
*                    }*
                } else {
                    $this->Flash->error(
                            __('Username or password is incorrect'), 
'default', [], 'auth'
                    );
                }
            }
    }

On Monday, March 30, 2015 at 2:49:46 AM UTC+7, nilay singh wrote:
>
> Hey In blog authentication there is admin and author based role can anyone 
> suggest me how can I check in login action if user is admin if yes then 
> redirect to admin controller and if it is author it go to author controller 
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to