I have a class representing my identity that contains a few pieces of information. Here is the short version.
class Auth_User {
private $id;
private $current_role;
public function __construct($id, $current_role) {
$this->id = (int) $id;
$this->current_role = (string) $current_role;
}
public function __wakeup() {
if ( /*$current_role is not valid*/ ) {
/*clear identity and redirect to login*/
{
}
}
My question how can I safely clear the identity and redirect to login in the wakeup method? If I do the following it seems to run in a infinite loop.
Zend_Auth::getInstance()->clearIdentity();
$this->_helper->redirector('index', 'index');