Elw*_*his 6 php cakephp login cakephp-1.3
我想检查一下,登录时是否激活了用户的帐户,但是蛋糕的Auth组件以我不知道如何控制的方式处理登录.Cake基本上使用空白登录功能,我不知道如何检查User.active的值.
提前致谢
Jam*_*mie 11
AuthComponent有一个属性,用于设置这样的附加条件,称为$ userScope.
只需在beforeFilter()Auth设置块中包含此行:
$this->Auth->userScope = array('User.active' => true);
Run Code Online (Sandbox Code Playgroud)
注意:以上内容适用于Cake 1.x. 2.x使用:
$this->Auth->scope = array('User.active' =>true);
Run Code Online (Sandbox Code Playgroud)
然后,您可以将登录方法留空,并且AuthComponent将在验证访问者时附加此额外条件.
您可以在此处查看所有其他属性:http: //book.cakephp.org/2.0/en/core-libraries/components/authentication.html#configuring-authentication-handlers
如果您不包含此额外范围,则非活动用户仍可以登录,并且您必须在检查后在login()方法中将其注销.