Monday, November 22, 2010

Re: Authentication against 2 different user tables

On Mon, Nov 22, 2010 at 9:31 AM, Johannes <fernerjohannes@gmail.com> wrote:
> Hello,
>
> I want to set up a new project, using CakePHP 1.3 and have one big
> problem.
>
> I have set up all the tables i need, but i have 2 "user-tables" called
> users and agents.
> I want to set up 2 different login sites, one for the users and one
> for the agents (who have more or the less CRUD-Gui for the items they
> are linked with).
>
> But i have no clue, how to tell cake, that only "agents" have access
> to the administration an not all the users.
> ---> Would one table "users" with acl be the best way?
>
> there is also one other thing, i have the tables:
> agents
> agents_events       -----> "administrating"
> agents_locations    -----> "administrating"
> users
> users_event          -----> "attending"
> locations_users     -----> "bookmarked"
>
> this is very convenient, because i have the agents and the users baked
> in their own controller, which i wouldn't have if the agents and users
> would be in one table, the problem is, that the agents and users have
> different actions & fields in the database.
>
> Is there an best-practice-way to have at least 2 different
> loginsystems? (e.g. Frontend / Backenduser) ?

Use a single users table for everyone, plus other models for the
different roles, eg. Agent and Member (or whatever makes most sense
for what you're currently calling a User). The users table should have
model and foreign_key columns. The only others necessary would be
password and username (or email, whatever), and maybe created. All of
the other data specific to each user type would go in its own table,
and specific logic in the model. In your login method, you could then
switch on $this->Auth->user('model') to decide where to redirect.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: