Re: Adding a field to the User in Session
Aha, thats much smarter. While I have your attention, if you dont mind. What is the proper way to handle when a group is not allowed to access a particular controller? I have setup my ACL and it appears to be working properly. But, and I thought this would happen automatically, how do I stop execution of the requested method and tell the user they dont have permission? (AppController::beforeFilter() pasted below) I have a difficult time understanding where Cake's magic stops and mine is supposed to take over sometimes. function beforeFilter() { /* * Dont check ACL if this is the Users controller and the login in action */ if ($this->name != 'Users' && !in_array($this->action, array('login', 'logout'))) { /* * check(ARO, ACO, [action]) * */ if ($this->Acl->check(array('model' => 'Group', 'foreign_key' => $this->Session->read('Auth.User.group_id')), $this- >name, '*')) { var_dump('Allowed'); } else { var_dump('Not Allowed'); return false; } } } On Dec 9, 1:56 pm, Jeremy Burns | Class Outfit wrote: > Don't do a redirect; place this in your app_controller beforeFilter: > > $this->Auth->autoRedirect = false; > > Then add the code in your users->login method to populate the Auth.User > session key and then redirect accordingly. > > Jeremy Burns > Class Outfit > > http://www.classoutfit.com > > On 9 Dec 2011, at 18:44:50, RhythmicDevil wrote: > > > > > > > > > Ok thats fair enough. I can do a redirect, get the Group and then > > redirect to the final destination. Actually that allows me to also get > > a default path per group too. > > > thanks > > > On Dec 9, 1:39 pm, Jeremy Burns | Class Outfit > > wrote: > >> Look at the autoRedirect property of the Auth component. It allows you to > >> perform logic after login but before redirect - perfect for what you need. > > >>http://book.cakephp.org/view/1265/AuthComponent-Variables#autoRedirec... > > >> Jeremy Burns > >> Class Outfit > > >>http://www.classoutfit.com > > >> On 9 Dec 2011, at 18:20:22, RhythmicDevil wrote: > > >>> Hi, > >>> I have Users and Groups. When a user logs in I want the group name to > >>> be part of the record that is stored in Session. Currently I get this: > > >>> array ( > >>> 'id' => '4', > >>> 'username' => 'swright', > >>> 'group_id' => '4', > >>> 'created' => '2011-12-05 11:36:30', > >>> 'modified' => '2011-12-05 11:36:30', > >>> ) > > >>> What I want is this: > > >>> array ( > >>> 'id' => '4', > >>> 'username' => 'swright', > >>> 'group_id' => '4', > >>> 'group' => 'administrators', > >>> 'created' => '2011-12-05 11:36:30', > >>> 'modified' => '2011-12-05 11:36:30', > >>> ) > > >>> I figured I could just fetch the group name in the login method after > >>> the user is logged in. However my login method never gets called when > >>> I submit the data. But the user is logged in and redirected to the > >>> appropriate controller/action. The method is called when the login > >>> page is first requested but upon submission of the form it does not > >>> seem to get called again. > > >>> So I poked around the Auth component but the login function does not > >>> contain and sort of redirect that I could see. I am using Acl and Auth > >>> so this probably has something to do with it. > > >>> Can you explain the execution chain for logging in a user when using > >>> Acl and Auth? > > >>> I think there's probably also a way to do it automatically by defining > >>> something in the User model but I am not sure. > > >>> Thanks. > > >>> -- > >>> Our newest site for the community: CakePHP Video > >>> Tutorialshttp://tv.cakephp.org > >>> Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp > >>> 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 > > Tutorialshttp://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
Re: Adding a field to the User in Session
Don't do a redirect; place this in your app_controller beforeFilter: $this->Auth->autoRedirect = false; Then add the code in your users->login method to populate the Auth.User session key and then redirect accordingly. Jeremy Burns Class Outfit http://www.classoutfit.com On 9 Dec 2011, at 18:44:50, RhythmicDevil wrote: > Ok thats fair enough. I can do a redirect, get the Group and then > redirect to the final destination. Actually that allows me to also get > a default path per group too. > > thanks > > > On Dec 9, 1:39 pm, Jeremy Burns | Class Outfit > wrote: >> Look at the autoRedirect property of the Auth component. It allows you to >> perform logic after login but before redirect - perfect for what you need. >> >> http://book.cakephp.org/view/1265/AuthComponent-Variables#autoRedirec... >> >> Jeremy Burns >> Class Outfit >> >> http://www.classoutfit.com >> >> On 9 Dec 2011, at 18:20:22, RhythmicDevil wrote: >> >> >> >> >> >> >> >>> Hi, >>> I have Users and Groups. When a user logs in I want the group name to >>> be part of the record that is stored in Session. Currently I get this: >> >>> array ( >>>'id' => '4', >>>'username' => 'swright', >>>'group_id' => '4', >>>'created' => '2011-12-05 11:36:30', >>>'modified' => '2011-12-05 11:36:30', >>> ) >> >>> What I want is this: >> >>> array ( >>>'id' => '4', >>>'username' => 'swright', >>>'group_id' => '4', >>>'group' => 'administrators', >>>'created' => '2011-12-05 11:36:30', >>>'modified' => '2011-12-05 11:36:30', >>> ) >> >>> I figured I could just fetch the group name in the login method after >>> the user is logged in. However my login method never gets called when >>> I submit the data. But the user is logged in and redirected to the >>> appropriate controller/action. The method is called when the login >>> page is first requested but upon submission of the form it does not >>> seem to get called again. >> >>> So I poked around the Auth component but the login function does not >>> contain and sort of redirect that I could see. I am using Acl and Auth >>> so this probably has something to do with it. >> >>> Can you explain the execution chain for logging in a user when using >>> Acl and Auth? >> >>> I think there's probably also a way to do it automatically by defining >>> something in the User model but I am not sure. >> >>> Thanks. >> >>> -- >>> Our newest site for the community: CakePHP Video >>> Tutorialshttp://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
Re: Adding a field to the User in Session
Ok thats fair enough. I can do a redirect, get the Group and then redirect to the final destination. Actually that allows me to also get a default path per group too. thanks On Dec 9, 1:39 pm, Jeremy Burns | Class Outfit wrote: > Look at the autoRedirect property of the Auth component. It allows you to > perform logic after login but before redirect - perfect for what you need. > > http://book.cakephp.org/view/1265/AuthComponent-Variables#autoRedirec... > > Jeremy Burns > Class Outfit > > http://www.classoutfit.com > > On 9 Dec 2011, at 18:20:22, RhythmicDevil wrote: > > > > > > > > > Hi, > > I have Users and Groups. When a user logs in I want the group name to > > be part of the record that is stored in Session. Currently I get this: > > > array ( > > 'id' => '4', > > 'username' => 'swright', > > 'group_id' => '4', > > 'created' => '2011-12-05 11:36:30', > > 'modified' => '2011-12-05 11:36:30', > > ) > > > What I want is this: > > > array ( > > 'id' => '4', > > 'username' => 'swright', > > 'group_id' => '4', > > 'group' => 'administrators', > > 'created' => '2011-12-05 11:36:30', > > 'modified' => '2011-12-05 11:36:30', > > ) > > > I figured I could just fetch the group name in the login method after > > the user is logged in. However my login method never gets called when > > I submit the data. But the user is logged in and redirected to the > > appropriate controller/action. The method is called when the login > > page is first requested but upon submission of the form it does not > > seem to get called again. > > > So I poked around the Auth component but the login function does not > > contain and sort of redirect that I could see. I am using Acl and Auth > > so this probably has something to do with it. > > > Can you explain the execution chain for logging in a user when using > > Acl and Auth? > > > I think there's probably also a way to do it automatically by defining > > something in the User model but I am not sure. > > > Thanks. > > > -- > > Our newest site for the community: CakePHP Video > > Tutorialshttp://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
Re: Adding a field to the User in Session
Look at the autoRedirect property of the Auth component. It allows you to perform logic after login but before redirect - perfect for what you need. http://book.cakephp.org/view/1265/AuthComponent-Variables#autoRedirect-1274 Jeremy Burns Class Outfit http://www.classoutfit.com On 9 Dec 2011, at 18:20:22, RhythmicDevil wrote: > Hi, > I have Users and Groups. When a user logs in I want the group name to > be part of the record that is stored in Session. Currently I get this: > > array ( >'id' => '4', >'username' => 'swright', >'group_id' => '4', >'created' => '2011-12-05 11:36:30', >'modified' => '2011-12-05 11:36:30', > ) > > What I want is this: > > array ( >'id' => '4', >'username' => 'swright', >'group_id' => '4', >'group' => 'administrators', >'created' => '2011-12-05 11:36:30', >'modified' => '2011-12-05 11:36:30', > ) > > > I figured I could just fetch the group name in the login method after > the user is logged in. However my login method never gets called when > I submit the data. But the user is logged in and redirected to the > appropriate controller/action. The method is called when the login > page is first requested but upon submission of the form it does not > seem to get called again. > > So I poked around the Auth component but the login function does not > contain and sort of redirect that I could see. I am using Acl and Auth > so this probably has something to do with it. > > Can you explain the execution chain for logging in a user when using > Acl and Auth? > > I think there's probably also a way to do it automatically by defining > something in the User model but I am not sure. > > Thanks. > > -- > 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
Adding a field to the User in Session
Hi, I have Users and Groups. When a user logs in I want the group name to be part of the record that is stored in Session. Currently I get this: array ( 'id' => '4', 'username' => 'swright', 'group_id' => '4', 'created' => '2011-12-05 11:36:30', 'modified' => '2011-12-05 11:36:30', ) What I want is this: array ( 'id' => '4', 'username' => 'swright', 'group_id' => '4', 'group' => 'administrators', 'created' => '2011-12-05 11:36:30', 'modified' => '2011-12-05 11:36:30', ) I figured I could just fetch the group name in the login method after the user is logged in. However my login method never gets called when I submit the data. But the user is logged in and redirected to the appropriate controller/action. The method is called when the login page is first requested but upon submission of the form it does not seem to get called again. So I poked around the Auth component but the login function does not contain and sort of redirect that I could see. I am using Acl and Auth so this probably has something to do with it. Can you explain the execution chain for logging in a user when using Acl and Auth? I think there's probably also a way to do it automatically by defining something in the User model but I am not sure. Thanks. -- 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