dquv73115 2014-09-25 19:42
浏览 55
已采纳

如何在CakePhp中为某些操作创建用户登录

I have a website with CakePHP, I want to create a user login only for the Add, Edit and Delete for each model, ie, anyone can enter any part of the site, but for these three views one login is required.

Doing the beforeFilter for each view that I would give free access would require too much time and, ultimately, difficult to maintain.

There is a simple way to do this?

  • 写回答

1条回答 默认 最新

  • dongtun3259 2014-09-25 20:34
    关注

    In appController beforeFilter callback allow by default all actions:

    // Allow all actions. CakePHP 2.0
    $this->Auth->allow('*');
    
    // Allow all actions. CakePHP 2.1
    $this->Auth->allow();
    

    Then in controller (or appController?) deny some of them:

    parent::beforeFilter(); // Must be before deny method, in other way you first deny add and then allow it
    $this->Auth->deny('add', 'edit');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改