문제

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

도움이 되었습니까?

해결책

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'));
        }
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top