UserGroupMember
Manages the membership of users within groups, tracking who belongs to which group, their role within the group, and the complete lifecycle of their membership. This junction table goes beyond simple user-to-group mapping by recording how users joined (invitation, request, automatic), who approved their membership, when they joined and will leave, and what special roles they have within the group (owner, moderator, member). It handles complex membership scenarios like temporary project assignments where a consultant joins for 3 months, or rotating leadership where the 'team lead' role passes between members monthly. The entity tracks membership status changes, from pending approval through active membership to eventual departure, maintaining history for audit purposes. It supports group-specific roles that are different from system-wide roles - someone might be a 'Viewer' globally but an 'Admin' within their department group. The entity also manages membership inheritance in hierarchical groups and handles conflicts when users belong to multiple groups with different permission sets. This detailed tracking is essential for compliance reporting ('Who had access to financial data last quarter?') and security investigations ('Which groups was this user part of when the breach occurred?').
Properties
| Property | Type | Mode | Description | Required |
|---|---|---|---|---|
| membershipId | uuid | stored | Unique identifier for this membership record | Required |
| group | UserGroup | stored | The group the user belongs to | Required |
| user | User | stored | The user who is a member | Required |
| memberRole | string | enum | User's role within this specific group Values: | Optional |
| joinedAt | DateTime | stored | When the user joined this group | Required |
| joinMethod | string | enum | How the user became a member Values: Example: | Required |
| invitedBy | User | stored | Who invited the user to join | Optional |
| approvedBy | User | stored | Who approved the membership request | Optional |
| approvedAt | DateTime | stored | When membership was approved | Optional |
| status | string | enum | Current membership status Values: | Required |
| statusReason | string | stored | Explanation for current status | Optional |
| expiresAt | DateTime | stored | When membership automatically expires | Optional |
| renewalDate | DateTime | stored | When membership needs renewal | Optional |
| isPrimary | boolean | stored | Whether this is user's primary group | Optional |
| isInherited | boolean | stored | Whether membership comes from parent group | Optional |
| inheritedFrom | UserGroup | stored | Parent group membership is inherited from | Optional |
| canLeave | boolean | stored | Whether user can leave voluntarily | Optional |
| canInvite | boolean | stored | Whether member can invite others | Optional |
| canManage | boolean | stored | Whether member can manage group settings | Optional |
| customPermissions | string | stored | JSON array of group-specific permissions Example: | Optional |
| lastActiveAt | DateTime | stored | Last activity within group context | Optional |
| contributionScore | integer | stored | Measure of member's group participation | Optional |
| leftAt | DateTime | stored | When user left or was removed | Optional |
| leftReason | string | enum | Why membership ended Values: | Optional |
| removedBy | User | stored | Who removed the user from group | Optional |
| notes | string | stored | Administrative notes about this membership | Optional |
| metadata | object | stored | Additional membership-specific data | Optional |
Examples
Example 1
{
"@type": "UserGroupMember",
"membershipId": "mem_abc123",
"memberRole": "admin",
"joinedAt": "2024-01-15T10:00:00Z",
"joinMethod": "invited",
"invitedBy": "user_cto",
"approvedBy": "user_cto",
"approvedAt": "2024-01-15T10:30:00Z",
"status": "active",
"isPrimary": true,
"isInherited": false,
"canLeave": true,
"canInvite": true,
"canManage": true,
"customPermissions": "[\"manage_team_budget\",\"approve_time_off\",\"conduct_reviews\"]",
"lastActiveAt": "2024-03-15T14:30:00Z",
"contributionScore": 847,
"metadata": {
"teamLead": true,
"directReports": 8
}
}Example 2
{
"@type": "UserGroupMember",
"membershipId": "mem_temp_789",
"memberRole": "guest",
"joinedAt": "2024-03-01T09:00:00Z",
"joinMethod": "requested",
"approvedBy": "user_project_manager",
"approvedAt": "2024-03-02T11:00:00Z",
"status": "active",
"statusReason": "External contractor for Q2 project",
"expiresAt": "2024-06-01T00:00:00Z",
"renewalDate": "2024-05-15T00:00:00Z",
"isPrimary": false,
"isInherited": false,
"canLeave": false,
"canInvite": false,
"canManage": false,
"customPermissions": "[\"view_project_docs\",\"comment_on_tasks\"]",
"lastActiveAt": "2024-03-14T16:00:00Z",
"contributionScore": 23,
"notes": "Contractor from TechCorp, working on API integration",
"metadata": {
"contractorCompany": "TechCorp",
"contractNumber": "CTR-2024-089"
}
}