错误:发生内部错误

时间:2017-02-01 19:15:34

标签: cakephp cakephp-3.0

我正在使用xampp上安装的cakephp 3。它运行正常。但现在登陆后我收到了错误。

数据库表关系:

users hasMany roles
roles有许多users
关系表:roles_users

AppController.php

$this->loadComponent('TinyAuth.Auth', [
                'loginAction' => [
                    'controller' => 'Users',
                    'action' => 'login'
                ],
                'loginRedirect' => [
                    'controller' => 'Users',
                    'action' => 'dashboard'
                ],
                'authError' => 'Did you really think you are allowed to see that?',
                'authenticate' => [
                    'Form' => [
                        'fields' => [
                            'username' => 'username',
                            'password' => 'password'
                        ],
                        // 'scope' => ['Users.active' => true],
                        'contain' => ['Roles']
                    ]
                ],                
            ]
        );

我在error.log文件中收到以下错误

  

2017-02-02 01:04:08错误:[Cake \ Core \ Exception \ Exception]丢失   用户会话中的TinyAuth角色ID字段(Auth.User.role_id)

1 个答案:

答案 0 :(得分:1)

看起来您正在使用多角色过程,但您可能忘记添加多角色启用

// in your app.php
    'TinyAuth' => [
        'multiRole' => true,
        ...
    ],
相关问题