Để có giải pháp toàn cầu, thêm quyền truy cậpKiểm soát bộ điều khiển cơ sở của bạn (theo mặc định protected/components/CController.php
).
public function filters(){
return array('accessControl');
}
public function accessRules()
{
return array(
array('allow',
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
Sau đó, trong bộ điều khiển với đăng nhập hành động chỉnh sửa của bạn accessRules
để cho phép tất cả người dùng để truy cập vào trang đăng nhập
public function accessRules()
{
return array_merge(array(
'allow',
'actions'=>array('login'),
'users'=>array('*'),
),parent::accessRules()
);
}
tôi không muốn đặt nó trong mỗi bộ điều khiển duy nhất, tôi cần giải pháp toàn cầu – rafal235
nơi tôi có thể tìm thấy 'thành phần/bộ điều khiển'? – Ruben
@ user2075220 sau đó tạo một BaseController và có bộ điều khiển này mở rộng BaseController –