Domanda

After login, I want to redirect user type admin to one page, and user type member to a another page. How?

È stato utile?

Soluzione

Your login function would be something like

public function login() {
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {
            $userType = $this->Auth->user('type');
            if ($userType == 'admin') {
               $this->redirect(array('controller' => 'admin', 'action' => 'dashboard'));
            } else {
               $this->redirect(array('controller' => 'users', 'action' => 'profile'));
            }
        } else {
            $this->Session->setFlash(__('Invalid username or password, try again'));
        }
    }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top