mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 04:19:32 +00:00
feat(organization): listUserInvitations adds the ability to list all invitations for a given user (#3121)
* feat(org): listUserInvitations This PR introduces in the org plugin. * chore: lint
This commit is contained in:
@@ -560,7 +560,7 @@ await authClient.organization.getInvitation({
|
||||
|
||||
### List Invitations
|
||||
|
||||
To list all invitations you can use the `listInvitations` function provided by the client.
|
||||
To list all invitations for a given organization you can use the `listInvitations` function provided by the client.
|
||||
|
||||
```ts title="auth-client.ts"
|
||||
const invitations = await authClient.organization.listInvitations({
|
||||
@@ -570,6 +570,30 @@ const invitations = await authClient.organization.listInvitations({
|
||||
})
|
||||
```
|
||||
|
||||
### List user invitations
|
||||
|
||||
To list all invitations for a given user you can use the `listUserInvitations` function provided by the client.
|
||||
|
||||
```ts title="auth-client.ts"
|
||||
const invitations = await authClient.organization.listUserInvitations()
|
||||
```
|
||||
|
||||
On the server, you can pass the user ID as a query parameter.
|
||||
|
||||
```ts title="api.ts"
|
||||
const invitations = await auth.api.listUserInvitations({
|
||||
query: {
|
||||
email: "user@example.com"
|
||||
}
|
||||
})
|
||||
```
|
||||
<Callout type="warn">
|
||||
The `email` query parameter is only available on the server to query for invitations for a specific user.
|
||||
</Callout>
|
||||
|
||||
|
||||
|
||||
|
||||
## Members
|
||||
|
||||
### Remove Member
|
||||
|
||||
Reference in New Issue
Block a user