Add a role column to the user info for role based access. I suggest using cakedc users plugin. When creating a new user you can specify a role. I use this code in /cotroller/users/login
if ($this->Auth->user()) { if($this->Auth->user('is_admin') == 1) { $this->Auth->redirect('/admin/users/users/dashboard'); } else if ($this->Auth->user('role') == 'agent') { $this->Auth->redirect('/agent/users/users/dashboard'); }else { $this->Auth->redirect('/users/users/dashboard'); } } On Thu, Aug 18, 2011 at 12:14 PM, Mohd Hasnol <hasnolm...@gmail.com> wrote: > Hi zaky, > > i already create agent table with user_id reference. But, i still cannot > login as agent, since my login function will recall username and password in > users table. There is no agent's info in the users table. Correct me if i > got wrong concept. > > Thanks. > > nOLL. > > On Thu, Aug 18, 2011 at 10:45 AM, Zaky Katalan-Ezra > <procsh...@gmail.com>wrote: > >> Use users plugin. >> Create an agent table with the additional attribute and user_id to >> reference the user. >> Make /users/register visible to admin only. >> After successful new user registration if the user role is agent, redirect >> to /admin/agent/add. >> If you choose to implement role based access you can check the user role >> in login function and redirect the user with the right prefix. >> >> On Thu, Aug 18, 2011 at 4:22 AM, Mohd Hasnol <hasnolm...@gmail.com>wrote: >> >>> Thanks.But how the agent would like to login since admin and agents use >>> same login page. i use users table for login function. how i can link agent >>> table to the login function? for my case,at first, admin will decide agents >>> username and password. Then,admin will give it to the agents and they could >>> change their password. >>> >>> Thanks. >>> >>> On Wed, Aug 17, 2011 at 5:21 PM, WebbedIT <p...@webbedit.co.uk> wrote: >>> >>>> ACL has little to do with this as your simply talking about which >>>> model to use when creating an Agent, which has more field than a >>>> standard User. >>>> >>>> There is no right answer and you have a choice of using either /users/ >>>> agentAdd(agentEdit) or /agents/add(edit). >>>> >>>> I personally prefer to keep my add and edit actions within their >>>> respective controllers so would use the Agent model and include the >>>> required User fields in the form. As long as you use $this->Agent- >>>> >saveAll(); cake will deal with associating the two records for you. >>>> >>>> HTH, Paul. >>>> >>>> On Aug 16, 5:28 am, Mohd Hasnol <hasnolm...@gmail.com> wrote: >>>> > FYI, Im using ACL for this case. >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > On Tue, Aug 16, 2011 at 12:26 PM, nOLL <hasnolm...@gmail.com> wrote: >>>> > > Hi, >>>> > >>>> > > Let say, I'm admin and i would like to add agents but i would like >>>> to >>>> > > use different model (not users model). For example, agents model. >>>> the >>>> > > reason i use different model because there is other attributes i >>>> would >>>> > > like to fill in rather than username and password in users model. >>>> What >>>> > > is the best solution for this? >>>> > >>>> > > Thanks. >>>> > > nOLL >>>> > >>>> > > -- >>>> > > Our newest site for the community: CakePHP Video Tutorials >>>> > >http://tv.cakephp.org >>>> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd >>>> help >>>> > > others with their CakePHP related questions. >>>> > >>>> > > To unsubscribe from this group, send email to >>>> > > cake-php+unsubscr...@googlegroups.com For more options, visit this >>>> group >>>> > > athttp://groups.google.com/group/cake-php >>>> >>>> -- >>>> Our newest site for the community: CakePHP Video Tutorials >>>> http://tv.cakephp.org >>>> Check out the new CakePHP Questions site http://ask.cakephp.org and >>>> help others with their CakePHP related questions. >>>> >>>> >>>> To unsubscribe from this group, send email to >>>> cake-php+unsubscr...@googlegroups.com For more options, visit this >>>> group at http://groups.google.com/group/cake-php >>>> >>> >>> -- >>> Our newest site for the community: CakePHP Video Tutorials >>> http://tv.cakephp.org >>> Check out the new CakePHP Questions site http://ask.cakephp.org and help >>> others with their CakePHP related questions. >>> >>> >>> To unsubscribe from this group, send email to >>> cake-php+unsubscr...@googlegroups.com For more options, visit this group >>> at http://groups.google.com/group/cake-php >>> >> >> >> -- >> Our newest site for the community: CakePHP Video Tutorials >> http://tv.cakephp.org >> Check out the new CakePHP Questions site http://ask.cakephp.org and help >> others with their CakePHP related questions. >> >> >> To unsubscribe from this group, send email to >> cake-php+unsubscr...@googlegroups.com For more options, visit this group >> at http://groups.google.com/group/cake-php >> > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > cake-php+unsubscr...@googlegroups.com For more options, visit this group > at http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php