Topic-icon Logout Failure in certain cases

Active Subscriptions:

None
10 years 7 months ago #36053 by colinM
SCLogin is very good but I have found a situation where it has a challenge. Only using Joomla login/logout no social ones involved.
Using the JCE Editor in Front end mode. If a user logs out whilst the front end editor is open, that is the user exits without doing a Save or Cancel in the Editor, then it fails. This is because the return url has hex encoding %xx characters such as
http%3A%2F%2Fwww.mywebsite.com%2Findex.php%2Flocal
instead of
http://www.mywebsite.com/index.php/local
There is a simple pragmatic fix shown below.

First I will describe my setup a little. Access to the front end editor and various other facilities only appear in the relevant menu when the person is logged in. The login is set to return to 'same page', but the logout is set to return to the home page. This is because I could not fathom out how to resolve the problem when using logout return to same when the page will not exist for access when I have logged out - so I did a simple practical solution the get over my 'challenge'. No doubt the profession coders will solve matters in a better way.

The simple fix, which could be implemented much, much better. Insert the following code as illustrated below into mod_sclogin.php around line 22.
$user = JFactory::getUser();
$jLoginUrl = $helper->getLoginRedirect('jlogin');
$jLogoutUrl = $helper->getLoginRedirect('jlogout');
//new code from here - need to 'undo' base64_encode
$camjLogoutUrl = base64_decode($jLogoutUrl);
// now do urldecode to replace any %xx character sequences with singe equivalent character, harmless if there  are none
$camjLogoutUrl2 = urldecode($camjLogoutUrl);
// uncomment line below if you want to see what is happening
//echo "logout1-$camjLogoutUrl-<br />logout2-$camjLogoutUrl2-<br />";
// now re encode in base64
$jLogoutUrl = base64_encode($camjLogoutUrl2);
// end of extra code
$registerType = $params->get('register_type');
$forgotLink = '';

Colin
The topic has been locked.
Support Specialist
10 years 7 months ago #36069 by alzander
Colin,
Thanks for the feedback. First, regarding:

This is because I could not fathom out how to resolve the problem when using logout return to same when the page will not exist for access when I have logged out

SCLogin module already has some magic in it to take care of this situation. When you set the Logout redirection to 'same page', we do a check to see if the current page is for Registered users.. if so, we change the logout redirection to the home page automatically.

As to the actual question, I'm not sure where those hex encodings are coming from. Can you help explain that more? If you've set the Logout redirection to a specific menu item, that link is stored in your database with the Joomla Menu Manager. It shouldn't be hex-encoded in your database. When the logout redirection is generated, we simply ask Joomla where that menu item is supposed to go and then base64_encode that.

With that said, do you know why your URL would be hex encoded in the first place? Something seems off on that. Is that hex encoding only happening on the article edit screens as well? If so, that would help narrow things down, but I'd still be confused as to why it's happening.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
10 years 7 months ago #36093 by colinM
Hi
Two things - first same page logout if not guest
If logout is set to same page && we go to a page that is 'registered', what happens is that instead of returning to the home page on logout the user is taken to the standard Joomla login page with the message you must login first. This confuses people as they have just logged out
I have seen the isMenuRegistered function and it does seem like it should work. However is is not getting called in the logout phase. I think this is because in getLoginRedirect the reference to $this->params->get('jlogout') [helper.php circa line 113] evaluates as false so getLinkFromMenu is not called. As a consequence the last part of getLoginRedirect is obeyed. This in my case generates a redirect of
http://www.mysite.com/index.php/component/users/?view=login
with the result as above.

Second item - need for urldecode
This happens if a user is logged on, is using the front end editor and decides to logout without using Save or Cancel to first exit the editor.
In this situation getLoginRedirect obeys the code
if (JRequest::getString('return'))
return JRequest::getString('return');
This comes back with a string containing %xx encodeded characters.so urldecode sorts it out. Probably need to use something like
if ((strpos($testurl, '/') !== false))
just in case the % should one day occur as the first character.

Hope this helps.

Colin
The topic has been locked.
Active Subscriptions:

None
10 years 7 months ago #36094 by colinM
Whoops,in above the
if ((strpos($testurl, '/') !== false))
should be
if ((strpos($testurl, '%') !== false)).

Colin
The topic has been locked.