你必須創建自己的身份驗證組件
,你必須執行,檢查,如果你的用戶可以登錄,如果是假否則返回他的數據陣列的功能。
像
\控制器\分量\身份驗證\ CompanyAuthenticate.php
App::uses('FormAuthenticate', 'Controller/Component/Auth');
class CompanyAuthenticate extends FormAuthenticate
{
public function authenticate(CakeRequest $request, CakeResponse $response)
{
$user = parent::authenticate($request, $response);
if(!$user)
return false;
else
{
//check company
// if company is ok return $user
// else return false
}
}
}
編輯:
當然你得告訴你,都在使用這種認證
的應用程序
所以在你的AppController中你必須這樣做:
public $components = array(
'Auth' => array(
'authenticate' => array('Company'),
// ... other options
),
// ... other components you wish to load
);
發展? –
對不起,cakePHP 2.4 – Albert
不能將用戶重定向到他的一個隨機公司(即alfabetical順序中的第一個公司),登錄後讓用戶在公司之間切換?您可以在您的UsersController登錄操作中執行重定向,然後您可以創建switchCompany操作 – arilia