Cake Auth userScope ?
Hi, if a user try to login and his account is not active yet the login will fail because of this: 'scope' = array('User.usr_active' = 1), Is there anyhow a way to catch this case to display a proper message to the user? Thanks for help!! -- 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: Cake Auth userScope ?
Simply be creating your own AuthExt component which overrides the default login() method: https://github.com/dereuromark/tools/blob/2.0/Controller/AuthExtComponent.php#L108 PS: the class is not intended for public use (kind of ugly still from 2008, only upgraded without cleanup to 2.x) - only for reference in this case Am Samstag, 14. April 2012 15:15:14 UTC+2 schrieb heohni: Hi, if a user try to login and his account is not active yet the login will fail because of this: 'scope' = array('User.usr_active' = 1), Is there anyhow a way to catch this case to display a proper message to the user? Thanks for help!! -- 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: Auth-userScope is getting ignored
Update: I found no the way with debug kit how to see the statement. And as I guessed, the userScope is not taking place: WHERE `User`.`username` = 'xx' AND `User`.`password` = 'xx' LIMIT 1 I added public function beforeFilter() { parent::beforeFilter(); $this-Auth-userModel = 'User'; $this-Auth-userScope = array('User.usr_active' = '1'); But still the active is not getting checked. -- 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: Auth-userScope is getting ignored
Update: even if add this for testing $this-Auth-fields = array('username' = 'test', 'password' = 'test' ); This is also ignored... -- 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: Auth-userScope is getting ignored
try this: $this-Auth-authenticate = array( AuthComponent::ALL = array( 'userModel' = 'User', 'fields' = array( 'username' = 'test', 'password' = 'test', ), 'scope' = array( 'User.usr_active' = 1, ) ), 'Form' ); http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html 2012/4/8 heohni heidi.anselstet...@consultingteam.de Update: even if add this for testing $this-Auth-fields = array('username' = 'test', 'password' = 'test' ); This is also ignored... -- 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 -- *Vitor Pacheco* *Skype: vitor.pacheco.costa Msn: vitor-...@hotmail.com* *GTalk: vitorpc...@gmail.com** **Cel.: 71 8626-7909 Tel.: 71 3378-5778 /** 71 3287-3475* -- 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
$this-Auth-userScope
In an effort to make sure that only active users can log into the application I've added the following in my app_controller function beforeFilter() { $this-Auth-userScope = array('User.active' = 1); } and the following in my login function under my users_controller function login() { if ($this-Session-read('Auth.User')) { $active = $this-Auth-user('active'); if ($active) { //(do stuff) } else { //(do other stuff) } } } but when testing I am still able to login with inactive users. Furthermore if I try to debug or echo in the app_controller- beforeFilter function it doesn't even print anything out which makes me thing the function isn't being called in the first place. I've read the cake documentation on the topic - what am i doing wrong here? -- 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: $this-Auth-userScope
Why are you reading the session? That assumes the user is already logged in. function login() { if(!empty($this-data)) { if($this-Auth-login($this-data){ .. code here } } } Might want to turn autoRedirect off? If you are using a beforeFilter in your users controller, be sure to add parent::beforeFilter(); at the top of the function so that it doesn't overwrite the app_controller's version. On 8 March 2011 21:36, DerekGardiner derek.gardi...@gmail.com wrote: In an effort to make sure that only active users can log into the application I've added the following in my app_controller function beforeFilter() { $this-Auth-userScope = array('User.active' = 1); } and the following in my login function under my users_controller function login() { if ($this-Session-read('Auth.User')) { $active = $this-Auth-user('active'); if ($active) { //(do stuff) } else { //(do other stuff) } } } but when testing I am still able to login with inactive users. Furthermore if I try to debug or echo in the app_controller- beforeFilter function it doesn't even print anything out which makes me thing the function isn't being called in the first place. I've read the cake documentation on the topic - what am i doing wrong here? -- 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 -- Kind Regards Stephen http://www.ninjacodermonkey.co.uk -- 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: Problems with Auth-userScope
yes i tried that but the problem still persists. I think it may have something wrong in the code i wrote but i cant seem to find it -- 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: Problems with Auth-userScope
I dont wanna use ACL. I was under the impresion if I had a db row that had usernamepassword admin user1 pass1 0 user2 pass2 1 by using Auth-userScope - user1 would be denied - user2 would be granted acess -- 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: Problems with Auth-userScope
User 1 would not be allowed to login. User 2 would be allowed to login. userScope is usually used for things like email activation (If the user clicks the private link in the email, it goes to a unique url, which then sets the userScope to 1 from 0 and that user can then login) On 11 February 2011 08:29, zero00 jmejia...@gmail.com wrote: I dont wanna use ACL. I was under the impresion if I had a db row that had usernamepassword admin user1 pass1 0 user2 pass2 1 by using Auth-userScope - user1 would be denied - user2 would be granted acess -- 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 -- Kind Regards Stephen @ NinjaCoderMonkey www.ninjacodermonkey.co.uk -- 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: Problems with Auth-userScope
Have you tried moving the line parent::beforeFilter() below the lines where you set the AuthComponent variables (or possibly removing it alltogether)? It may be that the AuthComponent's loginAction is being processed in the AppController's beforeFilter(), before the userScope is being set in your AdminsController. On Feb 11, 12:29 am, zero00 jmejia...@gmail.com wrote: I dont wanna use ACL. I was under the impresion if I had a db row that had username password admin user1 pass1 0 user2 pass2 1 by using Auth-userScope - user1 would be denied - user2 would be granted acess -- 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
Problems with Auth-userScope
Ok so the problem is that i have users who are admins and users who are not. but the users who dont have admin acess which is represent by 0 on the db still get on it //Database DB T Schema: id username varchar password varchar admin tiny_int(1) //Controller class class AdminsController extends AppController { var $name = 'Admins'; var $uses = array('User'); function beforeFilter() { parent::beforeFilter(); $this-Auth-loginAction = array('controller' = 'admins', 'action' = 'login'); $this-Auth-userScope = array('User.admin' = '1'); } } ? Thanks in advance -- 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: Problems with Auth-userScope
Hi, I think you are talking about ACL, not authentication. $this-Auth-userScope used as condition while doing login and it doesn't provide mechanism to access or deny particular user to particular page. Hope that helps. Amit Badkas PHP Applications for E-Biz: http://www.sanisoft.com On Fri, Feb 11, 2011 at 11:07 AM, zero00 jmejia...@gmail.com wrote: Ok so the problem is that i have users who are admins and users who are not. but the users who dont have admin acess which is represent by 0 on the db still get on it //Database DB T Schema: id username varchar password varchar admin tiny_int(1) //Controller class class AdminsController extends AppController { var $name = 'Admins'; var $uses = array('User'); function beforeFilter() { parent::beforeFilter(); $this-Auth-loginAction = array('controller' = 'admins', 'action' = 'login'); $this-Auth-userScope = array('User.admin' = '1'); } } ? Thanks in advance -- 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