Cakephp Migration:使用Security和Auth Component的两种Auth类型

时间:2014-01-26 10:20:53

标签: security cakephp authentication migration

我刚将我的应用程序从Cake 1.3迁移到2.4.4,我无法解决以下问题:

在我的应用程序中,用户需要在注册其个人帐户之前进行身份验证(使用仅由社区知道的唯一用户+密码)。

在版本1.3中,使用安全性和auth组件非常简单:

class AppController extends Controller {
var $components = array('Auth', 'Security');

function beforeFilter() {                       
    // Used for 
    $this->Security->loginOptions = array('type'=>'basic');            
    $this->Security->loginUsers = array(
        'sampleUser' => 'smaplePassword' // same user + PW for all users
    );
    $this->Security->requireLogin();

    // Used for specific user login
    $this->Auth->allow('display');
    $this->Auth->loginAction = array('controller' => 'Home', 'action' => 'index'); 
    $this->Auth->loginRedirect = array('controller' => 'Game', 'action' => 'index'); 
    $this->Auth->loginError = "Benutzername und/oder Passwort falsch!";
    $this->Auth->authError = "Keine Berechtigung, bitte einloggen!";
}

}

现在在版本2中,安全组件已迁移到auth。我努力寻找解决方案,但直到现在才能想出办法。

甚至可以使用蛋糕2.4.4来做到这一点吗?

1 个答案:

答案 0 :(得分:0)

我不知道安全组件,但你可以使用Auth组件进行CakePHP 1.3中的登录。

我建议您首先将登录转换为v1.3中的Auth组件,然后从那里进行迁移。

请查看我的separate answer,以便从1.3 - 2.x迁移CakePHP身份验证。