Open sakicnet opened 7 years ago
@sakicnet can you submit this as a PR please Emir
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?
@brianteeman Hi Brian, is this enough? https://github.com/sakicnet/joomla-cms/commit/d6fa7f9b4e6f206a4fadc9ba9ea275c4308faf36
@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.
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.
@mbabker that would probably require extending the JMenu class because its $user property is protected?
JMenu::load()
is public. There's no need to make any other changes than to (re-)call the load()
method.
Wait, nevermind. Realizing you need an updated JUser
object too.
Either way, you shouldn't reconstruct an object. A new one should be loaded in replacing the existing one.
JMenu::load() doesn't fix the issue. What we need is $menu->user->load($id) OK, will try that.
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();
.
If we can change JMenu then great. New PR: https://github.com/joomla/joomla-cms/pull/15839 Feel free to modify / improve. Thanks.
Reopen because both PR that should fix them are closed https://github.com/joomla/joomla-cms/pull/21230 and https://github.com/joomla/joomla-cms/pull/15839
Same issue as #11541
Please close this and re-open #21230
Maintainers please action the request above
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
Steps to reproduce the issue
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