我想使用Security :: allowedControllers和Security :: allowedActions。所以我有一個控制器,它看起來或多或少像這樣CakePHP:使用安全:: allowedControllers和安全:: allowedActions
class AppController extends Controller {
var $components = array('Security'); //other components
//other stuff
}
class BookController extends AppController {
function beforeFilter() {
parent::beforeFilter();
$this->Security->allowedControllers = array('Users');
$this->Security->allowedActions = array('view');
$this->Security->RequireAuth = array('search', 'results');
}
//other stuff
}
行動「搜索」顯示了一個表單,然後調用「結果」來顯示搜索結果。我故意試圖破壞。
對於我所瞭解的$ this-> Security-> allowedControllers和$ this-> Security-> allowedActions,我應該只能從控制器'Users'的操作'視圖'中獲取POST數據。特別是行爲「結果」應該將我重定向到一個黑洞,因爲它從控制器「書籍」的操作「搜索」中獲取POST數據。
但事實並非如此。我甚至可以製作交叉控制器請求,並且永遠不會被黑匣子,所以我想我沒有正確使用這個變量。什麼是觸發跨控制器請求控制的正確方法?
您可能希望將「PHP」標籤添加到這個問題,以吸引更多的觀衆(即使它是非常特殊的蛋糕)。 – 2010-01-31 17:55:33
而且*完全*無關:)我只是點擊進入您的主頁,'Gasse'不能用德語中的'ß'縮寫。以防萬一。 – 2010-01-31 17:57:20
謝謝德國小費,我會解決它! ;-) – Andrea 2010-01-31 18:09:52