Allowing a Specific Page in Cakephp

后端 未结 2 758
没有蜡笔的小新
没有蜡笔的小新 2020-12-20 23:09

I understand how to allow certain controller actions for non-logged in users. But, I can\'t find any documentation on how to allow access to specific pages. The controller

2条回答
  •  温柔的废话
    2020-12-20 23:55

    I'm afraid you can't do that using the standard functions that AuthComponent gives you. You have to create your own logic for that in the pages_controller's display action.

    Something like (pseudo-code style)

    # in app/controllers/pages_controller.php
    var $allowedPages = array('one', 'two');
    
    function display($page) {
        if(in_array($page, $allowedPages) || $this->User->loggedin) {
            $this->render($page);
        } else {
            $this->render('not_allowed');
        }
    }
    

提交回复
热议问题