fixed server side team invitation

This commit is contained in:
Zai Shi 2024-11-08 19:47:32 +01:00
parent d84b29f5f4
commit 7d4d2c18b6
3 changed files with 24 additions and 3 deletions

View File

@ -645,7 +645,7 @@ export class StackClientInterface {
email: string,
teamId: string,
callbackUrl: string,
session: InternalSession | null,
session: InternalSession,
}): Promise<void> {
await this.sendClientRequest(
"/team-invitations/send-code",

View File

@ -502,4 +502,26 @@ export class StackServerInterface extends StackClientInterface {
null,
);
}
async sendServerTeamInvitation(options: {
email: string,
teamId: string,
callbackUrl: string,
}): Promise<void> {
await this.sendServerRequest(
"/team-invitations/send-code",
{
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
email: options.email,
team_id: options.teamId,
callback_url: options.callbackUrl,
}),
},
null,
);
}
}

View File

@ -1967,10 +1967,9 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
throw new Error("Cannot invite user without a callback URL from the server. Make sure you pass the `callbackUrl` option: `inviteUser({ email, callbackUrl: ... })`");
}
await app._interface.sendTeamInvitation({
await app._interface.sendServerTeamInvitation({
teamId: crud.id,
email: options.email,
session: null,
callbackUrl: options.callbackUrl ?? constructRedirectUrl(app.urls.teamInvitation),
});
},