Cakephp 2.x に認証コンポーネントのヘルパーはありますか?
現在、次のように AppController のビューに $Auth オブジェクトを渡すだけです。
$this->set('Auth', $this->Auth);
私は周りを検索しましたが、デフォルトで利用できるヘルパーはないようです。Auth::loggedIn() のようなビューで Auth コンポーネントの関数のいくつかが必要です。
ヘルプ?
Cakephp 2.x に認証コンポーネントのヘルパーはありますか?
現在、次のように AppController のビューに $Auth オブジェクトを渡すだけです。
$this->set('Auth', $this->Auth);
私は周りを検索しましたが、デフォルトで利用できるヘルパーはないようです。Auth::loggedIn() のようなビューで Auth コンポーネントの関数のいくつかが必要です。
ヘルプ?
AuthComponent ::user関数は静的に呼び出すことができます:
if (AuthComponent::user()) {
// user is logged in
}
または、セッションから読み取るだけなので、セッション (コンポーネント/ヘルパー/クラス) を介して同じ情報を見つけることもできます。
if ($this->Session->read('Auth.User')) {
// user is logged in
}
Auth コンポーネント (または任意のコンポーネント) をビューに渡すことはお勧めできません。
認証コンポーネントはまだ存在します: http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html