Welcome to the Cookbook

loading...
Please login to continue

5.2.5.3 deny

allow で認証を行わないことを許可したアクション一覧から、一部のアクションを取り除きたいこと場合が出てくるかもしれません。 これを行うには次のようにします。

    function beforeFilter() {
        $this->Auth->authorize = 'controller';
        $this->Auth->allow('delete');
    }

    function isAuthorized() {
        if ($this->Auth->user('role') != 'admin') {
            $this->Auth->deny('delete');
        }

        ...
    }
  1. function beforeFilter() {
  2. $this->Auth->authorize = 'controller';
  3. $this->Auth->allow('delete');
  4. }
  5. function isAuthorized() {
  6. if ($this->Auth->user('role') != 'admin') {
  7. $this->Auth->deny('delete');
  8. }
  9. ...
  10. }