U4-10808 - New member roles/groups not accessible when save or examine events fired

Created by Christian 05 Jan 2018, 17:47:54 Updated by Daryl Naumann 28 Feb 2018, 13:16:27

What did you do? Added an Examine GatheringNodeData event. Went to the members section of Umbraco, selected a member, assigned a new role. Noticed that it doesn't seem possible to see the updated member roles.

When changing the roles a member belongs to, upon saving the member, within the Examine GatheringNodeData event for the member index (or within the MemberService.Saved event), the updated list of roles for the member is not available when calling GetAllRoles. Instead, only the previous roles are available, meaning it's not possible to correctly do anything with the new roles data. We are attempting to add the assigned roles as an Examine index, but are unable to do so as the list isn't updated until after the save has been completed.

What did you expect to happen? We would expect that the updated roles list be available to use.

What actually happened? Only the previous roles are in the roles list. When saving the member for a second time, then the roles become available, but this means the user would need to click the save button twice.

E.g.

private void OnGatheringNodeData(object sender, IndexingNodeDataEventArgs e) { var roles = _memberService .GetAllRoles(e.NodeId); // Add roles to index... }

The roles variable only contains the roles that the member had prior to saving, rather than the new ones added/removed.

Also the same when using the Saved event MemberService.Saved += SavedMember; ... SavedMember(IMemberService sender, SaveEventArgs e)

Looking at the Umbraco code in MemberController, it looks like perhaps the member is saved, but the roles aren't actually added for the member until afterwards?

Comments

Daryl Naumann 28 Feb 2018, 13:16:27

I've noticed this too, and would also like it resolved please. I'm recording details of the added users in a separate database (don't ask!), and can get everything except the added role/group, which is very important. I've checked in both Roles.IsUserInRole and Roles.GetUsersInRole, and only previously added users exist in both the _Created and _Saved event.


Priority: Normal

Type: Bug

State: Submitted

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.7.7, 7.8.1

Due in version:

Sprint:

Story Points:

Cycle: