Skip to content

Commit b68fdec

Browse files
Verify new organization joinees (#20161)
1 parent 65bc968 commit b68fdec

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

components/server/src/orgs/organization-service.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,32 @@ export class OrganizationService {
262262
if (await this.teamDB.hasActiveSSO(invite.teamId)) {
263263
throw new ApplicationError(ErrorCodes.NOT_FOUND, "Invites are disabled for SSO-enabled organizations.");
264264
}
265+
const user = await this.userDB.findUserById(userId);
266+
if (!user) {
267+
throw new ApplicationError(ErrorCodes.INTERNAL_SERVER_ERROR, `User ${userId} not found`);
268+
}
269+
265270
// set skipRoleUpdate=true to avoid member/owner click join link again cause role change
266271
await runWithSubjectId(SYSTEM_USER, () =>
267272
this.addOrUpdateMember(SYSTEM_USER_ID, invite.teamId, userId, invite.role, {
268273
flexibleRole: true,
269274
skipRoleUpdate: true,
270275
}),
271276
);
277+
278+
try {
279+
// verify the new member if this org is a paying customer
280+
if (
281+
(await this.stripeService.findUncancelledSubscriptionByAttributionId(
282+
AttributionId.render({ kind: "team", teamId: invite.teamId }),
283+
)) !== undefined
284+
) {
285+
await this.userService.markUserAsVerified(user, undefined);
286+
}
287+
} catch (e) {
288+
log.warn("Failed to verify new org member", e);
289+
}
290+
272291
this.analytics.track({
273292
userId: userId,
274293
event: "team_joined",

0 commit comments

Comments
 (0)