php - How do I make a user management and login module with roles in a separate table

689

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?

484

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

229

Answer

Solution:

http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

Change fieldroles torole_id and add relation Role hasMany User (User belongsTo Role)

People are also looking for solutions to the problem: php - Detect if a page is visited by a bot

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.