-
☆ A M B ☆
- 24,524 Posts
I don't see one of these when the user logs in. I think this only applies to Manager users, to store the state of the various Manager interface elements, like the Tree.
That sounds right. The user information must be stored *somewhere* or you wouldn't have the problem. The fact that the code I posted doesn't solve it might be considered a bug.
-
☆ A M B ☆
- 24,524 Posts
Actually it does solve the basic problem, the user can now access the associated protected resources without having to log out and log in again. It's just puzzling where that function is getting its information from. I hesitate to get too fond of it until that little puzzle gets solved.
Sorry, what function are you referring to?
-
☆ A M B ☆
- 24,524 Posts
Your solution, which otherwise is working great. The function that's not reflecting the newly added group is $modx->user->getUserGroups();
Let's back up. How are you adding the user to the user group?
-
☆ A M B ☆
- 24,524 Posts
if(!($modx->user->isMember('Protected'))) {
$modx->user->joinGroup('Protected');
...
}
-
☆ A M B ☆
- 24,524 Posts
I take it back. Something is definitely messed up.
Go to
http://np2.sottwell.modxcloud.com/, look at the session. Log in as "testing", password "testing123". Now log out. Click the "Secured" link, then the Home link.
There seems to be inconsistent behavior with the session.
And why does it still have data for user 0 when you're logged in?
[ed. note: sottwell last edited this post 11 years ago.]
I think we've found a bug:
Here's what I suspect is the problem code in getUserGroups():
$groups= $_SESSION["modx.user.{$id}.userGroups"];
And here's the relevant code in joinGroup():
unset($_SESSION["modx.user.{$this->get('id')}.userGroupNames"]);
Notice that they're referencing two different array members.
If you add this to your code after the joinGroup(), it may work:
$userId = $modx->user->get('id');
unset($_SESSION["modx.user.{$userId}.userGroups"]);
-
☆ A M B ☆
- 24,524 Posts
After a lot of removing groups in the Manager and logging in and logging out, I see a lot of very odd behavior in the SESSION. I'm still trying to pin down the exact behavior and what triggers it. Basically it's not changing to reflect changes made in the Manager, let alone in code, in some cases, and it doesn't always contain the same amount of information.