2011-05-10 47 views
0

當我提交登錄 我得到
錯誤:無法找到LoginsController。當我提交登錄時cakephp auth組件

這AppController的

class AppController extends Controller { 
var $helpers = array('Html','Form','Ajax','Javascript','Session'); 
    var $components = array('Auth','Session'); 

    function beforeFilter() { 
    //parent::beforeFilter(); 
    $this->Auth->userModel = 'Member'; 
    $this->Auth->allow('*'); 
    $this->Auth->authError='Please Login for view this page'; 
    $this->Auth->loginError = 'Username or Password does not match'; 
    $this->Auth->loginRedirect = array('Controller'=>'Members','action'=>'dashboard'); 
    $this->Auth->logoutRedirect = array('Controller'=>'Members','action'=>'index'); 

    ($this->set('admin',$this->isadmin())); 
    ($this->set('logged_in',$this->logged_in())); 
    ($this->set('userUsername',$this->userUsername())); 
} 

function isadmin(){ 
    $admin = FALSE; 
    if($this->Auth->user('priority') == 'admin') 
      { 
     $admin = TRUE; 
    } 
    return $admin; 
} 
    function logged_in(){ 
    $logged_in = FALSE; 
    if ($this->Auth->user()) 
       { 
      $logged_in = TRUE; 
     } 
     return $logged_in; 
} 
function userUsername(){ 
    $userUsername = NULL; 
    if($this->Auth->user()) 
      { 
     $userUsername = $this->Auth->Member('username'); 
    } 
    return $userUsername; 
} 

}

我嘗試在計算器進行搜索,但我無法找到答案謝謝

+0

我應該切換到authsome還是不行,因爲我開始討厭auth組件,但是使用ACL時沒有問題或難度增加。 – krissanawat 2011-05-10 18:22:29

+0

顯示您的用戶控制器。不需要你的'LoginsController'。另外,控制器名稱應該始終是單數! – Tim 2011-05-11 09:38:00

回答

-1

正在發生的事情是,你需要創建一個延伸的LoginsController AppController並在該控制器中處理登錄的邏輯。當你去到url/login時,它會自動尋找那個控制器,除非你創建一個指定的路由。

+0

我不知道我在YouTube上的教程中關注 – krissanawat 2011-05-11 05:12:33

+0

這不是auth組件的工作方式。 Theres不需要登錄控制器! – Tim 2011-05-11 09:38:37