Prof.No Time

try to take a coffee cup and get relaxed, this is my current solution/
tips/tricks for the moment

1)put this in your AppController class
final protected function _logout() {
        if (!empty($this->Cookie)) {
                //this ensures if you were using the Cookie component along 
with the
Auth component (the famous remember me checkbox)
                //and you have saved the credentials inside cookie
                //you should delete the credentials from the cookie when you 
log out
                //no need to verify if you have already saved the credentials 
inside
cookie, no error is thrown
                $this->Cookie->del($this->Auth->sessionKey);
        }
        return $this->Auth->logout();
}

2)your UsersController class logout() method should be now like this
public function logout() {
        $this->redirect($this->_logout());
}

3)your UsersController class beforeFilter() method/callback should be
now like this
public function beforeFilter() {
        ...
        parent::beforeFilter();
        //please specify the always allowed actions... logout should be the
first one of course
        $this->Auth->allow
('logout','forgotpassword','resetpassword','activate','register'/* put
here any other always-allowed action*/);
        if ($this->Auth->user()) {
                if (in_array($this->params['action'],array
('forgotpassword','resetpassword','register','activate'))) {
                        //if you are forgetting your password,
                        //if you resetting your password,
                        //if you are registering as a new user,
                        //or if you are activating you new accout via url
                        //you should not be logged in ... yea this is logic
                        $this->_logout();
                } elseif($this->params['action']=='login') {
                        //you are already logged in, no need to login again
                        $this->redirect($this->Auth->redirect());
                }
        } elseif ($this->params['action']=='logout') {
                //you are already logged out, no need to log out again
                $this->redirect($this->Auth->redirect());
        }
        ...
}

now have a nice baking day....
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to