No Code Attached Yet J4 Issue bug
avatar Flowman
Flowman
23 Mar 2021

Steps to reproduce the issue

This is a weird one to explain.

I got a multi language site with associated login menu items. The language filter is configured for automatic language change.

When I am logged out and trying to access a menu item with access permissions https://test.com/en/somepagewithaccess , I will be redirected to the login page. The return URL is set to the correct page I want to get redirected to. When I sign in instead of getting to the correct return page I get to the login page instead.

Noticed in languagefilter onUserLogon event the code is a bit funky.

$uri = new JUri($this->app->getUserState('users.login.form.return'));

We retrieve the 'users.login.form.return' data and the next step is to check if it has an ItemId. This will fail for an SFE url as we don't have an item id for the redirect URL. Next step is to fall back to the active menu associated item and it will go to that.

Expected result

After login user should be redirected to the right return URL.

Actual result

After login redirected to the wrong page.

System information (as much as possible)

Joomla 3.9.25
PHP 7.3

Additional comments

avatar Flowman Flowman - open - 23 Mar 2021
avatar joomla-cms-bot joomla-cms-bot - change - 23 Mar 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 Mar 2021
avatar Flowman Flowman - change - 23 Mar 2021
The description was changed
avatar Flowman Flowman - edited - 23 Mar 2021
avatar sandramay0905
sandramay0905 - comment - 17 Apr 2021

@infograf768 sorry to call you but do you have a comment for this issue?

avatar infograf768
infograf768 - comment - 17 Apr 2021

@Flowman
please explain in details what you mean with
When I am logged out and trying to access a menu item with access permissions https://test.com/en/somepagewithaccess

what kind of menu item and which access is it set to? (if it is not Public or Guest, it may not display at all).
Or does the link to that menu item is placed in an article for example?

avatar Flowman
Flowman - comment - 18 Apr 2021

I have a component that sends out an email to a menu item that has access permission of "registered" for an approval function.

First create "Login Form" menu items for each language.

Then create any type of menu item with any registered access permission, copy the URL when you are logged in, logout from the page and try to access the URL. When you login you will not get redirected to the correct URL when you have the "automatic language change" option in the language filter plugin enabled.

Check the code rows I attached in my first post and you will see what is going on.

avatar infograf768
infograf768 - comment - 19 Apr 2021

Hmm. Still unclear.
Let's say we have 2 languages: en-GB and fr-FR

Site default language: ?
User login site default language: ?
The mail is including the link to registered menu item. As you specifiy the /en/ as url language code, it means that menu item is tagged to en-GB.
Is it always the same menu item tagged to en-GB? I.e https://test.com/en/somepagewithaccess.
Or do you have also another one tagged to fr-FR, i.e. https://test.com/fr/somepagewithaccess?

If yes, are these associated?

Is the user who is going to login has en-GB as site default language?

What exactly are the settings for the language filter? Please post a screenshot.

Now, what are the redirect urls of each login menu item? Specify their language tag.
Are these the ones specified above and associated?

If all this is as stated, then I confirm the issue. I get here the Log Out page after logging.

The solution for you is to use the Internal URL as login redirect and not the Menu Item

avatar infograf768
infograf768 - comment - 19 Apr 2021

Wait a bit. I have to test something else.
I have the feeling that when we introduced the “login_redirect_menuitem” as an alternative to url we may have forgotten to take care of that param in the llanguage filter. Not sure though.

avatar Flowman
Flowman - comment - 19 Apr 2021

@infograf768

Wanted to record a gif for you, but Joomla lanucher is a bit broken and does not launch an new site for me.

avatar sandramay0905
sandramay0905 - comment - 19 Apr 2021

Joomla lanucher is a bit broken and does not launch an new site for me

is reported: joomla/joomla-websites#1614 (comment)

avatar infograf768
infograf768 - comment - 20 Apr 2021

@Bakual @bembelimen
Can you have a look at this?

login_redirect_menuitem was added for 3.6.0 #10249

avatar Flowman
Flowman - comment - 20 Apr 2021

Here we go, fired up a quick docker to record this.

As you can see when "automatic language change" option is disabled, it redirects to the right page. When enabled it fails back to the login page.

joomla_error

Hope this helps to fix the issue. The same code exists in Joomla 4 and will fail in similar way.

avatar Flowman
Flowman - comment - 20 Apr 2021

@Bakual @bembelimen
Can you have a look at this?

login_redirect_menuitem was added for 3.6.0 #10249

This has nothing to do with the login_redirect_menuitem as I don't configure this on the menus. This is just a pure access redirect. Part of the SiteApplication->authorise from 3.2.0.

It's just funky maybe untested code, as it will break in SFE because the URI has not Itemid yet. Gave the details in my first post where it breaks.

avatar infograf768
infograf768 - comment - 20 Apr 2021

This has nothing to do with the login_redirect_menuitem as I don't configure this on the menus.

You have not replied to me concerning the way your login menu items are configured:

The return URL is set to the correct page I want to get redirected to.

Please reply to my questions. Are you using redirects or not?
if yes WHAT type of redirect? Menu item or Internal Url?

Screen Shot 2021-04-20 at 09 56 19

avatar Flowman
Flowman - comment - 20 Apr 2021

Default config.

image

And still it does not use the redirect menu part. It is just no access redirect from here

protected function authorise($itemid)

I already tried to explain where the code is breaking :)

avatar Flowman
Flowman - comment - 20 Apr 2021

Here are the steps to do on a brand new multi language enabled site.

joomla_error2

I cannot show the issue more clear than this.

avatar infograf768
infograf768 - comment - 20 Apr 2021

I understood perfectly what you did...
It can't use a redirect as you do not define a redirect when automatic_change is set.

I quote you

The return URL is set to the correct page I want to get redirected to.

Your statement in the description of the issue is therefore somehow wrong as you rely on Default.
In this case Default means the login form itself and it shows the logout button when automatic_change is set.

As I proposed above as an alternative, use Internal URL and add the correct full url in the field, i.e. https://test.com/en/somepagewithaccess.

Can't help more. Sorry. Take off automatic_change in the meanwhile if it does not fit your needs.

Maybe someone else will be able to help you.

(Note: looks like we still have an issue with Menu Item which has not been taken care of fully in the languagefilter.)

avatar Flowman
Flowman - comment - 20 Apr 2021

Okay lets re-explain as my first comment was not clear.

If I send a link to someone that you need to have a "registered" access level to access. He copies the link into the web browser. Now he is thrown to the login page as he does no have access to the page as a guest. When he logins in he should be redirected to the page sent in the link, not the login page itself.

I don't relay on the Default redirect. I relay on the code I shown a couple of times in the SiteApplication authorise.

$this->setUserState('users.login.form.data', array('return' => \JUri::getInstance()->toString()));

and this part here cannot handle it as it is sad.

$uri = new JUri($this->app->getUserState('users.login.form.return'));

The code is there to handle it but it is broken, and that is why I am reporting it, as I don't like to hack the core on my sites.

This whole thing work perfectly fine when SEF is not enabled and the "Itemid" is sent with the URL.

Hopefully someone else with have a go and can fix the issue as just disabling automatic_change is not really a fix. Else take the whole broken code out and don't have an option to use it.

avatar Quy Quy - change - 15 Jul 2021
Labels Added: J3 Issue J4 Issue
avatar Quy Quy - labeled - 15 Jul 2021
avatar Quy Quy - labeled - 15 Jul 2021
avatar Flowman Flowman - change - 15 Jul 2021
Title
[3.9] languagefilter automatic language change
[4.0] [3.9] languagefilter automatic language change
avatar Flowman Flowman - edited - 15 Jul 2021
avatar rdeutz rdeutz - change - 24 Aug 2022
Labels Added: No Code Attached Yet
Removed: J3 Issue ?
avatar rdeutz rdeutz - unlabeled - 24 Aug 2022
avatar Hackwar Hackwar - change - 22 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 22 Feb 2023

Add a Comment

Login with GitHub to post a comment