0
votes

I am using cakephp 3 installed on xampp. It was running fine. but now I got the error after login.

database table relation:

users hasMany roles
roles hasMany users
relational table: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']
                    ]
                ],                
            ]
        );

I got the following error in error.log file

2017-02-02 01:04:08 Error: [Cake\Core\Exception\Exception] Missing TinyAuth role id field (Auth.User.role_id) in user session

1
Apparently, you're using something called TinyAuth, and it expects a role id field to be present, but it's not. Is this a new plugin you've added?Greg Schmidt
Are you using TinyAuth multi-role ? that means you have a table name like roles_users ?tarikul05
if Possible please share your table structuretarikul05

1 Answers

1
votes

It looks you are using muli-role process, but you may be forgot to add multi-role enable

// in your app.php
    'TinyAuth' => [
        'multiRole' => true,
        ...
    ],