Skip to content

Commit 7d4d2c1

Browse files
committed
fixed server side team invitation
1 parent d84b29f commit 7d4d2c1

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

packages/stack-shared/src/interface/clientInterface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ export class StackClientInterface {
645645
email: string,
646646
teamId: string,
647647
callbackUrl: string,
648-
session: InternalSession | null,
648+
session: InternalSession,
649649
}): Promise<void> {
650650
await this.sendClientRequest(
651651
"/team-invitations/send-code",

packages/stack-shared/src/interface/serverInterface.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,4 +502,26 @@ export class StackServerInterface extends StackClientInterface {
502502
null,
503503
);
504504
}
505+
506+
async sendServerTeamInvitation(options: {
507+
email: string,
508+
teamId: string,
509+
callbackUrl: string,
510+
}): Promise<void> {
511+
await this.sendServerRequest(
512+
"/team-invitations/send-code",
513+
{
514+
method: "POST",
515+
headers: {
516+
"Content-Type": "application/json"
517+
},
518+
body: JSON.stringify({
519+
email: options.email,
520+
team_id: options.teamId,
521+
callback_url: options.callbackUrl,
522+
}),
523+
},
524+
null,
525+
);
526+
}
505527
}

packages/stack/src/lib/stack-app.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,10 +1967,9 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
19671967
throw new Error("Cannot invite user without a callback URL from the server. Make sure you pass the `callbackUrl` option: `inviteUser({ email, callbackUrl: ... })`");
19681968
}
19691969

1970-
await app._interface.sendTeamInvitation({
1970+
await app._interface.sendServerTeamInvitation({
19711971
teamId: crud.id,
19721972
email: options.email,
1973-
session: null,
19741973
callbackUrl: options.callbackUrl ?? constructRedirectUrl(app.urls.teamInvitation),
19751974
});
19761975
},

0 commit comments

Comments
 (0)