2012-04-17 38 views
5

Tôi đang cố gắng để di chuyển mã của tôi từ địa phương đến máy chủ khi tôi cố gắng đăng nhập vào ứng dụngAuthorization không được tìm thấy trong CakePHP

enter image description here

Here is my AppController 
class AppController extends Controller{ 
    /* Determines what logged-in users access to */ 
    var $components = array('Auth','Session'); 

    public function isAuthorized($user){ 
     return true; 
    } 

    public function beforeFilter(){ 
     $userdetails = array(); 
     $this->Auth->autoRedirect = false; 
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); 
     $this->Auth->loginRedirect = array('controller' => 'matches', 'action' => 'index'); 
     $this->Auth->authorize = 'controller'; 
     $this->Auth->authError= 'You need permissions to access this page'; 
     $this->Auth->allow('users'); 
     $this->set('Auth',$this->Auth); 
     $userdetails = $this->Auth->user(); 
     $this->set('myUser', $userdetails['username']); 
     $this->set('myRole', $userdetails['user_role_id']); 
     $this->set('pStatus', $userdetails['password_status']); 
    } 
} 


Here is my Login Action in UsersController 
public function login(){ 
     $this->Auth->autoRedirect = false; 
     $id = $this->Auth->user('id'); 
     if(empty($id)){ 
      if($this->request->is('post')){ 
       if($this->Auth->login()){ 
        $this->redirect($this->Auth->redirect()); 
       }else{ 
        $this->Session->setFlash('Invalid Username or password'); 
       } 
      } 
     }else{ 
      $this->redirect(array('action'=>'index')); 
     } 
    } 

Thanks for the help

Trả lời

12

Phần bạn cho phép các bộ điều khiển trong số beforeFilter của mình phải được viết hoa chính xác:

Vì vậy:

$this->Auth->authorize = 'Controller';

Thay vì:

$this->Auth->authorize = 'controller';

Đó tuyên bố đặc biệt cố gắng tìm controllerAuthorize.php và cần được tìm kiếm ControllerAuthorize.php. Điều này không gây ra một vấn đề trên Windows, nhưng nó trên hệ thống Unix.

+0

Tôi có thể bỏ lỡ những vấn đề nhỏ này như thế nào. bạn đã làm cho người đàn ông của tôi ngày –

+1

Có vẻ như câu nói cũ "ma quỷ là trong các chi tiết" vẫn là sự thật. Và bạn được chào đón. ;) – mensch

+2

Nó cũng không được chú ý trên Mac OS X. Chỉ cần nói ... '^ ^ –

Các vấn đề liên quan