我允许在网站帐户和Facebook用户上进行两种登录..
对于facebook用户,密码字段将为空。
所以我在登录操作中执行这样的查询,以确定用户是否是Facebook用户。
if(!empty($this->data)){
$this->User->recursive = -1;
$facebook_user = $this->User->find('count', array('conditions' => array('email' => $this->data['User']['email'], 'password' => null)));
if($facebook_user == 1){
$this->Auth->loginError = "Looks like you have used Facebook connect to Login to the website.";
}
}
如果$ facebook_user == 1那么我想要显示特定的LoginError。
默认情况下,我将在过滤前的LoginError设置为
$this->Auth->loginError = "Please check the Username and Passwords";
但即使$ facebook_user设置为1
,Facebook LoginError也不会被分配用户控制器中的BeforeFilter
function beforeFilter() {
$this->Auth->fields = array('username' => 'email', 'password' => 'password');
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'harsha');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'killer');
$this->Auth->loginError = "Please check the Username and Passwords";
$this->Auth->authError = "You are not authorized to be here Bitch.";
$this->Auth->allow('*');
}
App Controller中的BeforeFilter()
function beforeFilter() {
$this->Auth->allow('*');
//$this->Auth->userScope = array('User.status' => 'active');
// Setting Admin Template
if(isset($this->params['admin'])) {
$this->layout = 'admin';
}
}