joomla/joomla-cms — pull request #3126 by clubnite (2014-02-16 18:23:00+00:00)
Title: Authorised Groups changes through the backend seem not to be detected in the frontend

Overcoming the issue that changes to a user's authorised groups are not detected and applied immediately to the related user while it is logged in i created a workaround which the following flow:

1. Changes made to a user object's groups and levels are catched by the onUserBeforeSave handler and dumped in a temporary plugin property.
2. After the changed data was stored, the user object's groups are newly loaded and compared to the previously dumped data. If something changed, the related user's session data is loaded from the database table by a new JSessionHelper, parsed into a human readable format and extended by a new entry indicating that the user's session must be refreshed.
3. If the related user is logged in, its session is automatically updated on every page reload, thus receiving the refresh-flag previously set in step 2. A newly added system plugin evaluates the user's session and in case this flag is detected, updates it's groups and levels, loads it's session data from the database, replaces it's user object property by the currently logged in user's object data and stores the update back into the database.

This allows for immediately applied groups and levels updates through an admin in the backend to a user without this user having to log out and in again for the changes to take effect.