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 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形