2011-11-29 131 views
2

我正在使用範圍登錄以確保用戶帳戶處於活動狀態。如果登錄失敗,我怎麼知道它是否失敗,因爲電子郵件不匹配或賬戶未被激活?登錄錯誤不知道爲什麼

此外,我不明白在cakephp食譜中的所有文檔,你可以看看我的組件數組中的auth部分?
在HTML表和SQL表中的電子郵件字段被稱爲「AccountEmail」
在HTML表和SQL表中的密碼字段被稱爲「帳戶密碼」
在活躍帳戶SQL錶行被稱爲「AccountActive」並且是一個int類型,如果用戶未激活,則值爲0,如果該值爲激活值,則爲1。

'Auth' => array(
     'logoutRedirect' => array('controller' => 'Accounts', 'action' => 'login'), 
     'authError' => 'You can\'t Access That Page', 
     'authorize' => array('Controller'), 
     'fields' => array('AccountEmail' => 'AccountEmail', 'AccountPassword' => 'AccountPassword'), 
     'scope' => array('AccountActive' => '1') 
    ) 

回答

3

您錯過了使用哪個身份驗證處理程序以及您的字段配置錯誤。

我假設你想使用形式登錄:

/** 
* Auth component configuration 
*/ 
public $components = array(
    'Auth'=> array(
    'logoutRedirect' => array(
     'controller' => 'Accounts', 
     'action' => 'login' 
    ), 
    'authError' => 'You can\'t Access That Page', 
    'authorize' => array('Controller'), 
    'authenticate' => array(
     'Form' => array(
     'fields' => array(
      'username' => 'AccountEmail', 
      'password' => 'AccountPassword' 
     ), 
     'scope' => array('AccountActive' => '1') 
    ) 
    ) 
) 
); 
+0

你知道如何檢測爲什麼登錄失敗? – Chris

+0

使用內置的表單身份驗證是不可能的。它只返回true或false。 –

相關問題