2011-11-29 130 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。 –

相关问题