# Task: Backend Workspace Invite Foundation ## Goal Implement the backend data model and endpoints needed to create, list, and accept workspace invites. ## Feature Spec - `docs/FEATURES/workspace-invites.md` ## Scope - Add a `WorkspaceInvite` persistence model with workspace id, normalized email, role, status, inviter, token data, timestamps, and expiration. - Add invite statuses for `Pending`, `Accepted`, `Cancelled`, and `Expired` without magic strings. - Add a manager-only endpoint to create workspace invites. - Add a manager-only endpoint to list workspace invites. - Prevent duplicate pending invites for the same normalized email in the same workspace. - Add a public endpoint to resolve an invite token for display-safe invite details. - Add an accept endpoint that validates token, status, expiration, and email match. - On acceptance, grant the invited role and `KnownClaims.WorkspaceScope` claim to the user. - Mark the invite as accepted in the same transaction as access grants. - Add backend tests for create, list, pending, accepted, expired, cancelled, duplicate, and email mismatch paths. ## Constraints - Keep backend code under `backend/src/Socialize.Api`. - Keep workspace feature code under `Modules/Workspaces`. - Do not expose raw token values in manager invite lists. - Frontend invite screens are covered by task 003 and task 004. ## Likely Files - `backend/src/Socialize.Api/Modules/Workspaces/Data/WorkspaceInvite.cs` - `backend/src/Socialize.Api/Modules/Workspaces/Data/WorkspaceInviteStatuses.cs` - `backend/src/Socialize.Api/Modules/Workspaces/Data/WorkspaceModelConfiguration.cs` - `backend/src/Socialize.Api/Modules/Workspaces/Handlers/CreateWorkspaceInvite.cs` - `backend/src/Socialize.Api/Modules/Workspaces/Handlers/GetWorkspaceInvites.cs` - `backend/src/Socialize.Api/Modules/Workspaces/Handlers/*Accept*Invite*.cs` - `backend/tests/Socialize.Tests/` ## Validation ```bash dotnet build backend/Socialize.slnx dotnet test backend/Socialize.slnx ```