我有許多與cakephp驗證開發有關的問題。爲此,我試圖使用名爲reviewers
的表,當然,它包含用戶名和密碼字段。CakePHP驗證與用戶問題以外的驗證表
我檢查,並從登錄表單發送正確的數據(用戶名和密碼)。
文件app_controller.php包含:
class AppController extends Controller {
var $components = array('Auth', 'Session', 'Cookie', 'P28n');
function beforeFilter() {
$this->Auth->authenticate = ClassRegistry::init('Reviewer');
Security::setHash('sha1'); // or sha1 or sha256
$this->Auth->userModel = 'Reviewers';
$this->Auth->fields = array('username' => 'username', 'password'=>'password');
$this->Auth->loginRedirect = array('controller' => 'reviewers', 'action' => 'view');
}
如何檢查和調試問題?我得到的錯誤是用戶名和密碼組合不正確。
是什麼驅使我瘋狂的是,我已經alredy開發simular功能之前,它的工作沒有問題........
請幫助。
更新:與cakephp debuggint工具,它看起來像auth組件永遠不會被調用。
你是否覆蓋你的beforeFilter()函數在控制器的地方? 確保調用parent :: beforeFilter(); – Matt 2011-05-16 14:24:21