Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.16.14

Bug #943 Logout problematic
Submitted: 2004-03-04 06:42 UTC
From: alain_d99 at freesurf dot ch Assigned: lsmith
Status: Closed Package: LiveUser
PHP Version: 4.2.1 OS: Windows
Roadmaps: (Not assigned)    
Subscription  


 [2004-03-04 06:42 UTC] alain_d99 at freesurf dot ch
Description: ------------ Hello, LiveUser.php: v1.79 I use the following schema: Config (partial): logout => array( 'trigger' => 'logout', 'destroy' => true ) File: AdminUser.php In the AdminUser.php, I use the code: $nLiveUser =& LiveUser::factory($Config); $nResult = $nLiveUser->init(); if(PEAR::isError($nResult)) HandleError1.... if(!$nResult) HandleError2... $if($nLiveUser->isLoggedIn()) {} else { HandleNotLogged... } The login process works perfectly well when I call: AdminUser.php?lang=fr if I call the following URL to logout: AdminUser.php?lang=fr&logout=1 the logout is made correctly and I go into the HandleError2. BUT I don't know if it is an error (cookies not set in browser by example when I log in) or a logout if I only use the LiveUser class, the 'status' gives me always LIVEUSER_STATUS_UNKNOWN. It would be great if the logout is clearly designed from LiveUser::init() if we don't use the key 'redirect' in the Config variable (here because I give lang=fr in the URL, a dynamic variable). Hope I am clear. Thank for your work, Alain

Comments

 [2004-03-05 14:49 UTC] lsmith
How about this: RCS file: /repository/pear/Perm_LiveUser/LiveUser.php,v retrieving revision 1.79 diff -u -r1.79 LiveUser.php --- LiveUser.php 2 Mar 2004 17:48:58 -0000 1.79 +++ LiveUser.php 5 Mar 2004 14:55:06 -0000 @@ -55,12 +55,12 @@ */ define('LIVEUSER_STATUS_IDLED', -1); define('LIVEUSER_STATUS_EXPIRED', -2); -define('LIVEUSER_STATUS_WRONG_LOGIN', -3); define('LIVEUSER_STATUS_ISINACTIVE', -4); define('LIVEUSER_STATUS_PERMINITERROR', -5); define('LIVEUSER_STATUS_AUTHINITERROR', -6); define('LIVEUSER_STATUS_UNKNOWN', -7); define('LIVEUSER_STATUS_AUTHNOTFOUND', -8); +define('LIVEUSER_STATUS_LOGGEDOUT', -9); /**#@-*/ /**#@+ @@ -769,7 +769,9 @@ } $this->_error = true; - $this->status = LIVEUSER_STATUS_UNKNOWN; + if (!is_null($this->status)) { + $this->status = LIVEUSER_STATUS_UNKNOWN; + } return false; } @@ -1076,6 +1078,8 @@ return false; } + $this->status = LIVEUSER_STATUS_LOGGEDOUT; + // If a callback function is set, call it if (!empty($this->_options['logout']['function']) && is_callable($this->_options['logout']['function'])) @@ -1483,10 +1480,14 @@ LIVEUSER_MISSING_LOGINFUNCTION => 'Login function not found', LIVEUSER_MISSING_LOGOUTFUNCTION => 'Logout function not found', LIVEUSER_COOKIE_ERROR => 'Remember Me cookie error', - LIVEUSER_STATUS_AUTHNOTFOUND => 'Cannot retrieve Auth object from session', + LIVEUSER_STATUS_EXPIRED => 'User session has expired', + LIVEUSER_STATUS_ISINACTIVE => 'User is set to inactive', + LIVEUSER_STATUS_UNKNOWN => 'Something went wrong in whatever you were trying to do' LIVEUSER_STATUS_PERMINITERROR => 'Cannot instantiate permission container', LIVEUSER_STATUS_AUTHINITERROR => 'Cannot instantiate authentication configuration', + LIVEUSER_STATUS_AUTHNOTFOUND => 'Cannot retrieve Auth object from session', LIVEUSER_STATUS_UNKNOWN => 'Something went wrong in whatever you were trying to do' + LIVEUSER_STATUS_LOGGEDOUT => 'User was logged out correctly' ); }
 [2004-03-05 16:04 UTC] lsmith
btw: there are two minor syntax errors with missing ',' in my patch
 [2004-03-06 09:23 UTC] alain_d99 at freesurf dot ch
Hello Smith, I copy your patch and test it. An error to correct in your patch in line ~769: if (!is_null($this->status)) { $this->status = LIVEUSER_STATUS_UNKNOWN; } return false; would be if (is_null($this->status)) { // STATUS MUST BE NULL $this->status = LIVEUSER_STATUS_UNKNOWN; } return false; And your solution works perfectly well, thanks Smith. Alain
 [2004-03-08 12:44 UTC] alain_d99 at freesurf dot ch
Hello Smith, another corrections with the introduction of LIVUSER_STATUS_LOGGEDOUT: processLogout() function sets the status variable, then in init() function: line: ~731 if ($lulogin && $this->_auth->loggedIn && $this->_auth->expireTime > 0 && $this->_auth->currentLogin > 0 && ($this->_auth->currentLogin + $this->_auth->expireTime) < time() ) { $this->expired = true; $this->status = LIVEUSER_STATUS_EXPIRED; $this->processLogout(true); } would be: if ($lulogin && $this->_auth->loggedIn && $this->_auth->expireTime > 0 && $this->_auth->currentLogin > 0 && ($this->_auth->currentLogin + $this->_auth->expireTime) < time() ) { $this->expired = true; $this->processLogout(true); //SWAP THE LAST TWO LINES $this->status = LIVEUSER_STATUS_EXPIRED; //NOW, OK } Must be made for LIVEUSER_STATUS_IDLED condition too. Thank, and greetings, Alain PS: my comment in #942 about redundancy of status, idled and expired variables can be problematic here, because logout() function use idled and expired variables and change the status variable
 [2004-03-08 12:47 UTC] lsmith
Nice spotted. I noticed those problems too. As such I will ensure that after a call to init the status is set properly, which means I will try to set the status as "late" as possible (right before the return) where possible and ensure its not overwritten anywhere else.
 [2004-03-08 21:10 UTC] lsmith
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.