0
votes

I have two (2) tables naming student and teacher. I'm using it for two separated table for requirements.

Student:

username | password | email | created | modified ( columns )

Teacher:

username | password | email | majorsub | etc.. ( columns )

$this->loadComponent('Auth',[
   'authenticate'=>[            
       'Teacher'=>[
       'authenticate'=>[
       'Basic' => ['userModel' => 'Teachers'],
        'Form' => ['userModel' => 'Teachers']
        ],
        'loginAction' => [
            'controller' => 'Teachers',
            'action' => 'login'
        ],
        [
        'loginRedirect' => [
            'controller' => 'Teachers',
            'action' => 'profile'
        ],
        'logoutRedirect' => [
            'controller' => 'Pages',
            'action' => 'home'
                ]
            ]
        ],
        'Students'=>[
            'authenticate'=>[
            'Basic' => ['userModel' => 'Students'],
            'Form' => ['userModel' => 'Students']
            ],
            'loginAction' => [
                 'controller' => 'Students',
                 'action' => 'login',

            ],
             [
           'loginRedirect' => [
                'controller' => 'Students',
                'action' => 'profile'
            ],
            'logoutRedirect' => [
                'controller' => 'Pages',
                'action' => 'home'
                ]
            ]

        ]
    ]);

I got an error : Authentication adapter "Teachers" was not found. How to create for this and is this right for two table login Auth configuration..

1
I'm not sure about the error, but why have two tables? Why not just one table with an extra column for 'role' ? - JayIsTooCommon
i was use tow table to clear relations in business logic.. - Ye Htun Z

1 Answers

0
votes

You may create a new table named accounts, and keep your teachers and students tables as the following:

Students:

account_id| created | modified ( columns )

Teachers:

account_id | majorsub | etc.. ( columns )

Accounts:

username | password | email |

this is the best practice I think