Add invitingOrganizations field on viewer

Expose viewer.invitingOrganizations: [Organization!]! returning the
organizations that have a live pending invitation directed at the
current identity (accepted_at IS NULL AND expires_at > NOW()). The
list is rendered under a "Pending invitations" section on the
memberships page and in the organization selector dropdown, so a user
already signed in with an existing identity can see which
organizations have invited them without having to dig through their
inbox.

The new field is gated by iam:invitation:list against the viewer's
own identity, so it does not loosen authorization on Organization
elsewhere. E2E coverage validates the live-pending case, the
no-invitation and post-accept cases, and a multi-org scenario.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-05-27 19:35:50 +02:00
parent f0b9acb748
commit e6b40957ee
11 changed files with 436 additions and 0 deletions

View File

@@ -151,6 +151,40 @@ func CreateUser(c *testutil.Client, attrs ...Attrs) string {
return result.CreateUser.ProfileEdge.Node.ID
}
func InviteUser(c *testutil.Client, profileID string) string {
c.T.Helper()
const query = `
mutation($input: InviteUserInput!) {
inviteUser(input: $input) {
invitationEdge {
node { id }
}
}
}
`
var result struct {
InviteUser struct {
InvitationEdge struct {
Node struct {
ID string `json:"id"`
} `json:"node"`
} `json:"invitationEdge"`
} `json:"inviteUser"`
}
err := c.ExecuteConnect(query, map[string]any{
"input": map[string]any{
"organizationId": c.GetOrganizationID().String(),
"profileId": profileID,
},
}, &result)
require.NoError(c.T, err, "inviteUser mutation failed")
return result.InviteUser.InvitationEdge.Node.ID
}
func CreateThirdParty(c *testutil.Client, attrs ...Attrs) string {
c.T.Helper()

View File

@@ -530,6 +530,10 @@ func NewClientWithNewSession(t testing.TB, from *Client) *Client {
return client
}
func (c *Client) GetEmail() string {
return c.email
}
func (c *Client) GetUserID() gid.GID {
return c.userID
}