複数のテーブルで 1 つの認証プロセスと「ユーザー」のみを処理する方法を知りたいです。ユーザー、管理者、アーティスト、チーム管理者の 4 つのユーザー テーブルがあり、すべて特定のフィールドがありますが、これらすべてのユーザーがホームページの 1 つのフォームのみを介して接続し、その後、特定のダッシュボードにリダイレクトされるようにしたいと考えています。
リダイレクトは問題ではなく、追加されたいくつかのルートは機能するはずですが、これをすべて可能にするためにどこを見たり開始したりすればよいか本当にわかりません。
乾杯、
ニコラス。
編集:これが最終的な解決策です(deizelに感謝)
App::import('Component', 'Auth');
class SiteAuthComponent extends AuthComponent {
function identify($user = null, $conditions = null) {
$models = array('User', 'Admin', 'Artist');
foreach ($models as $model) {
$this->userModel = $model; // switch model
$this->params["data"][$model] = $this->params["data"]["User"]; // switch model in params/data too
$result = parent::identify($this->params["data"][$model], $conditions); // let cake do its thing
if ($result) {
return $result; // login success
}
}
return null; // login failure
}
}