私は CakeDC プラグインの使用で同じ問題に遭遇しました。それらの多くにはドキュメントがほとんどまたはまったくありません。
ただし、「ゼロ」のドキュメントはありません。ほとんどの設定方法は、 github ページの下部のread me で確認できます。また、これを AppController::beforeFilter() メソッド内に配置する必要があります。
$this->Auth->authorize = 'controller';
$this->Auth->fields = array('username' => 'email', 'password' => 'passwd');
$this->Auth->loginAction = array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'admin' => false);
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
$this->Auth->authError = __('Sorry, but you need to login to access this location.', true);
$this->Auth->loginError = __('Invalid e-mail / password
combination. Please try again', true);
$this->Auth->autoRedirect = true;
$this->Auth->userModel = 'User';
$this->Auth->userScope = array('User.active' => 1);
if ($this->Auth->user()) {
$this->set('userData', $this->Auth->user());
$this->set('isAuthorized', ($this->Auth->user('id') != ''));
}
また、次のisAuthorized()
ような単純な関数が必要です。
public function isAuthorized() {
return true;
}
さらに、「ログイン」アクションを許可する必要があります (これには、プラグイン ファイルの編集が含まれます)。'login' を$this->Auth->allow()
in に追加するだけusers_controller.php
です。