php - How do I make a user management and login module with roles in a separate table
The problem I have is this: I have in my requirements a Users table and a Roles table separated.
users(id, login, password, id_role, name, last name, telephone, ...) roles(id, role, description)
I already have read and followed the authentication example here but it has the role in the same table as the user's data. I don't know how can I relate both tables in cakePHP, especially in a login module. Can someone please help me?
Answer
Solution:
You should read the CakePHP cookbook. The next topic after the simple authentication and authorization chapter is how to build an ACL-controlled application, which is what you’re after: http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html
Answer
Solution:
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
Change field
roles
torole_id
and add relation Role hasMany User (User belongsTo Role)