goldsky / Lingua

MODX's Lexicon switcher for front-end interface
18 stars 11 forks source link

lingua.selector causing manager to log out #41

Open muzzwood opened 9 years ago

muzzwood commented 9 years ago

Testing out Lingua for the first time. Placed the selector snippet on the home resource to test. Works fine until I go back to the manager which presents me with the login screen as soon as I try to load another manager page. It only happens when I click on the language link in the selector drop down on the web context. Modx 2.3.3

Any ideas what could be causing this?

Edit: I've tried deleting the cache and removing all cookies.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9737839-lingua-selector-causing-manager-to-log-out?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1919378&utm_medium=issues&utm_source=github).
muzzwood commented 9 years ago

It appears to only happen on the resource set by the "site_start" setting. Works fine on any other resource. And If I set site_start to a different resource, the original one then works fine.

muzzwood commented 9 years ago

Tried a fresh modx install. All worked perfectly until I turned Friendly URLs on. Some kind of issue going on there.

muzzwood commented 9 years ago

On further examination, it appears the wrong URIs are being generated. I have no idea why that's causing the manager to be logged out but it is anyway...

In my .htaccess file I've got: RewriteEngine On RewriteBase /mysite

If I delete the modx cache and clear my cookies, I can load up the resource with lingua.selector on the web context and the link shows it is pointed to http://localhost/mysite/?lang=zh This is correct and if I click on the link, it works and I don't get logged out of the manager.

Problem is, if I look at where the link is pointing on this newly loaded page, it shows: http://localhost//mysite/index.html?lang=en

Note the double slash // just after localhost!

Clicking this link will log me out of the manager.

muzzwood commented 9 years ago

Ok I think I've worked it out.

In the lingua.selector snippet, line 206 needs to be changed from: $pageURL = $parseUrl['scheme'] . '://' . $parseUrl['host'] . '/' . $parseUrl['path'] . $itemUri;

to $pageURL = $parseUrl['scheme'] . '://' . $parseUrl['host'] . $parseUrl['path'] . $itemUri;

sottwell commented 9 years ago

I would think this is going to work in some cases but not in others. The logout issue was only affecting me on Localhost, with the .htaccess RewriteBase set to /subdir/. On the MODX Cloud it never happens. This fix does stop the problem on localhost. I haven't checked what it would do on the Cloud installation. I wonder if it's only an issue in a subdir installation?