doutou6803 2012-08-23 05:57
浏览 45
已采纳

CakePHP 2.2.1(稳定版)中$ this-> auth-> authorize(cakephp 1.3)的变化是什么?

I am upgrading an app from CakePHP 1.3 to CakePHP 2.2.1 .

We are implementing ACL and in AppController I saw

if (isset($this->Auth)) {
            if ($this->use_acl) {
                $this->Auth->authorize = 'actions';
            }

As a variable declaration I have already made changes to the following :

var $components = array(
        'Auth' => array(
            'authenticate' => array(
                'Form' => array(
                'fields' => array('username' => 'email', 'password' => 'password')
                )
            ),
            'loginAction' => array(
                'admin' => false, 'prefix' => false, 'controller' => 'users', 
                'action' => 'login')
        ),
        'Session', 'Facebook.Connect');

does it still require me to keep:

$this->Auth->loginAction = array('admin' => false, 'prefix' => false, 'controller' => 'users', 'action' => 'login');

The code work may sound ugly but, that is how upgrades are! ;)

Also, can I use the $this->Auth-> 'auth properties' in 2.2.1 as it was possible in 1.3 ?

  • 写回答

1条回答 默认 最新

  • douxiong4250 2012-08-23 06:23
    关注

    As usual, the best place to get started with questions like this is the manual. Then, post the results of your tests rather than your code and a broad question.

    That said, the first block of code you posted looks like a custom variable on your end $this->use_acl. I've never seen that used in CakePHP, so there's some flag your setting in your app to use 'actions'.

    The second block of code looks pretty standard. It should work. Yes, you still need to specify a login action so that when a user tries to navigate to a page that is protected, then he/she will be redirected to the login. That said, there are differences in the login process as noted in the manual link above. You should take a look at the differences as to when a password is hashed and the login() function itself as they both have changed. The fact you are using ACL shouldn't matter much as far as Authentication differences between the two version.

    Your last question Also, can I use the $this->Auth-> 'auth properties' in 2.2.1 as it was possible in 1.3 ?, the answer is yes. You should take a look at the AuthComponent.php file in the lib/Cake folder. It's heavily commented about the information you are asking about here. There are even examples.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测