http://book.cakephp.org/view/1268/userScope
Place it in your App Controller, in beforeFilter
i.e.
$this->Auth->userScope = array('User.active' => 1);
If active is not set to 1 it will not allow the user to login.
Much easier.
On 24 February 2011 21:24, Rob <[email protected]> wrote:
> I'm following this tutorial to add email account activation
>
> http://www.jonnyreeves.co.uk/2008/06/cakephp-activating-user-account-via-email/
> I'm using cake 1.3 and I'm using auth and acl in my application
>
> Now onto the problem.
>
> on login, I want to check to see if the user's account has been
> activated, so following the tutorial I add
> if ($this->data) {
> // Use the AuthComponent’s login action
> if ($this->Auth->login($this->data)) {
> // Retrieve user data
> $results = $this->User-
> >find(array(‘User.username’ => $this->data[‘User’][‘username’]),
> array(‘User.active’), null, false);
> // Check to see if the User’s account
> isn’t active
> if ($results[‘User’][‘active’] == 0) {
> // Uh Oh!
> $this->Session->setFlash(‘Your
> account has not been activated yet!’);
> $this->Auth->logout();
> $this->redirect(‘/users/
> login’);
> }
> // Cool, user is active, redirect post
> login
> else {
> $this->redirect(‘/’);
> }
> }
> }
>
> to my login function in my users_controller. The only problem is that
> it's never entering that if statement. It seems that it doesn't think
> $this->data has anything in it.
>
> I'm thinking this has something to do with the automagic elements of
> Auth, but I'm not sure.
>
> Anyone have any ideas why this is happening
>
> --
> 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
> [email protected] 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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php