ログアウト後のログインが上手くできなくてハマったのでメモしておく。
class AppController extends Controller { public $components = array( 'Auth' => array( 'loginRedirect' => array('controller' => 'hoge', 'action' => 'index'), 'loginAction' => array('controller' => 'hoge', 'action' => 'login'), 'authenticate' => array( 'Form' => array( 'userModel' => 'Hoge', 'fields' => array( 'username' => 'email', ), 'scope' => array( 'Hoge.is_public' => 1, ), ), ), ), 'Session' ); public function beforeFilter() { parent::beforeFilter(); } }
class HogeController extends AppController { public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow(array('login', 'logout', 'fuga'));// loginとlogoutも記述しておく } public function login() { if ($this->Auth->login()) { $this->redirect($this->Auth->redirect()); } else { $this->Session->setFlash(__('Invalid username or password, try again')); } } public function logout() { $this->redirect($this->Auth->logout()); } }