No Code Attached Yet bug
avatar sakicnet
sakicnet
5 May 2017

Steps to reproduce the issue

  • Install Joomla 3.7 (or 3.7.1-dev)
  • Create a menu link with Access set to Registered (e.g. /test)
  • Enable System - Language Filter plugin (required for multi-lingual sites)
  • Login on frontend with "Remember me" checkbox ticked
  • Wait 15 minutes for session to expire ;) (not really, just remove your session cookie, or delete the session record from #__session table)
  • Visit the protected page (e.g. /en/test)

Expected result

You should be automatically logged in and land on open protected page.

Actual result

You are redirected to frontpage with message:
Error: You are not authorised to view this resource.
If your homepage requires access then you end up on 403 page.

System information (as much as possible)

What happens is that the language filter plugin builds the menu with access levels before the remember plugin had a chance to login the user. The menu is built with access levels of the guest user and updates only on refresh. So, on first visit, after the session expires, the menu thinks it's a guest and denies the access.

The quick fix is to re-build the menu after the remember plugin has logged in the user.
Here is the Gist, line 66: https://gist.github.com/sakicnet/f2b8e2486011093d08e544423d8e5124

Additional comments

avatar sakicnet sakicnet - open - 5 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 5 May 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 May 2017
avatar sakicnet sakicnet - edited - 5 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 5 May 2017
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 5 May 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 May 2017
Category Authentication Front End
avatar brianteeman
brianteeman - comment - 5 May 2017

@sakicnet can you submit this as a PR please Emir

avatar alikon
alikon - comment - 5 May 2017

i wonder, can we do in an alternative way just loading first plg_system_remember plugin and after plg_system_languagefilter changing the system plugin order?

avatar sakicnet
sakicnet - comment - 5 May 2017

@brianteeman Hi Brian, is this enough? sakicnet@d6fa7f9

@alikon: no, not really. Remember plugin does the login, which triggers onUserLogin events, which builds the menu before user is logged in. So it would involve bigger structural changes to fix it.

avatar mbabker
mbabker - comment - 5 May 2017

We shouldn't be direct calling __construct() again after an object is already constructed. Especially because it could result in class properties being changed. What you really need to do is call the load() method.

avatar sakicnet
sakicnet - comment - 5 May 2017

@mbabker that would probably require extending the JMenu class because its $user property is protected?

avatar mbabker
mbabker - comment - 5 May 2017

JMenu::load() is public. There's no need to make any other changes than to (re-)call the load() method.

avatar mbabker
mbabker - comment - 5 May 2017

Wait, nevermind. Realizing you need an updated JUser object too.

avatar mbabker
mbabker - comment - 5 May 2017

Either way, you shouldn't reconstruct an object. A new one should be loaded in replacing the existing one.

avatar sakicnet
sakicnet - comment - 5 May 2017

JMenu::load() doesn't fix the issue. What we need is $menu->user->load($id)
OK, will try that.

avatar mbabker
mbabker - comment - 5 May 2017

Putting public setters for the properties (at least a setUser() method) would help. Then you'd just need to do $this->app->getMenu()->setUser($user)->load();.

avatar sakicnet sakicnet - reference | f4985f3 - 5 May 17
avatar sakicnet
sakicnet - comment - 5 May 2017

If we can change JMenu then great. New PR: #15839
Feel free to modify / improve.
Thanks.

avatar zero-24 zero-24 - close - 5 May 2017
avatar zero-24 zero-24 - change - 5 May 2017
The description was changed
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-05-05 14:37:25
Closed_By zero-24
avatar zero-24 zero-24 - close - 5 May 2017
avatar HLeithner HLeithner - reopen - 21 Jun 2020
avatar HLeithner
HLeithner - comment - 21 Jun 2020

Reopen because both PR that should fix them are closed #21230 and #15839

avatar HLeithner HLeithner - change - 21 Jun 2020
Status Closed New
Closed_Date 2017-05-05 14:37:25
Closed_By zero-24
avatar HLeithner HLeithner - reopen - 21 Jun 2020
avatar AndySDH
AndySDH - comment - 7 Oct 2020

Same issue as #11541

avatar AndySDH
AndySDH - comment - 7 Oct 2020

Please close this and re-open #21230

avatar brianteeman
brianteeman - comment - 23 Aug 2022

Maintainers please action the request above

avatar zero-24 zero-24 - change - 23 Aug 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-08-23 19:33:08
Closed_By zero-24
Labels Added: No Code Attached Yet
Removed: ?
avatar zero-24 zero-24 - close - 23 Aug 2022
avatar zero-24
zero-24 - comment - 23 Aug 2022

That PR is against staging which does not exists anymore and the PR can not be reopend but need to be created against 4.x-dev

avatar zero-24 zero-24 - change - 23 Aug 2022
Status Closed New
Closed_Date 2022-08-23 19:33:08
Closed_By zero-24
avatar zero-24 zero-24 - reopen - 23 Aug 2022
avatar jwaisner jwaisner - change - 10 Oct 2022
Labels Added: ?
avatar jwaisner jwaisner - labeled - 10 Oct 2022
avatar Hackwar Hackwar - change - 18 Feb 2023
Labels Added: bug
avatar Hackwar Hackwar - labeled - 18 Feb 2023
avatar Hackwar Hackwar - change - 21 Feb 2023
Labels Removed: ?
avatar Hackwar Hackwar - unlabeled - 21 Feb 2023

Add a Comment

Login with GitHub to post a comment