-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: team invite links #10110
fix: team invite links #10110
Conversation
CAL-2160 Team invites aren't working for non-users
Found a bug? Please fill out the sections below. 👍 Issue SummaryIntroduced in #8355 Seems like invites to external users aren't being sent when there's more than one. Steps to Reproduce
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead? The current DB schema has a wrong unique constrain on teamID for VerificationToken, also seems like a Team can only have 1 active VerificationToken at a time. Actual Results
Expected Results
Technical details
EvidenceCreated a team and bulk-invited 3 new memebers. Only the last one had a relationship with the team. Invited a new one and this one got the relationship with the team now. So now previous invites are stuck in limbo. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for following the naming conventions! 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for review
@@ -83,7 +82,7 @@ export default function Signup({ prepopulateFormValues, token, orgSlug }: Signup | |||
}; | |||
|
|||
return ( | |||
<LicenseRequired> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LicenseRequired only works for logged in users. All users landing will be logged off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we dont need this for this component anyway. great catch!
@@ -114,7 +115,16 @@ export async function getTeamWithMembers(id?: number, slug?: string, userId?: nu | |||
...eventType, | |||
metadata: EventTypeMetaDataSchema.parse(eventType.metadata), | |||
})); | |||
return { ...team, metadata: teamMetadataSchema.parse(team.metadata), eventTypes, members }; | |||
/** Don't leak invite tokens to the frontend */ | |||
const { inviteTokens, ...teamWithoutInviteTokens } = team; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also to keep previous frontend signature
@@ -0,0 +1,2 @@ | |||
-- DropIndex | |||
DROP INDEX "VerificationToken_teamId_key"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A team can have multiple tokens. Dropped the unique requirement
@@ -270,7 +270,7 @@ model Team { | |||
parent Team? @relation("organization", fields: [parentId], references: [id], onDelete: Cascade) | |||
children Team[] @relation("organization") | |||
orgUsers User[] @relation("scope") | |||
inviteToken VerificationToken? | |||
inviteTokens VerificationToken[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A team may have multiple tokens
@@ -310,7 +310,7 @@ model VerificationToken { | |||
expiresInDays Int? | |||
createdAt DateTime @default(now()) | |||
updatedAt DateTime @updatedAt | |||
teamId Int? @unique | |||
teamId Int? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing that only the most recent invite had the proper team relationship.
@@ -22,7 +22,7 @@ export const createInviteHandler = async ({ ctx, input }: CreateInviteOptions) = | |||
const token = randomBytes(32).toString("hex"); | |||
await prisma.verificationToken.create({ | |||
data: { | |||
identifier: "", | |||
identifier: "invite-link-for-teamId-" + teamId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only to distinguish the copy link token VS the each individual email.
🤖 Meticulous spotted visual differences in 46 of 180 screens tested: view and approve differences detected. Last updated for commit c4b4892. This comment will update as new commits are pushed. |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
Current Playwright Test Results Summary✅ 88 Passing - Run may still be in progress, this comment will be updated as current testing workflow or job completes... (Last updated on 07/12/2023 08:42:23pm UTC) Run DetailsRunning Workflow PR Update on Github Actions Commit: c4b4892 Started: 07/12/2023 08:40:35pm UTC
|
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Managed Event Types tests Can create managed event type
Retry 2 • Retry 1 • Initial Attempt |
0.88% (3)3 / 339 runsfailed over last 7 days |
12.09% (41)41 / 339 runsflaked over last 7 days |
📄 packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Popup Tests should be able to reschedule
Retry 1 • Initial Attempt |
2.38% (1)1 / 42 runfailed over last 7 days |
97.62% (41)41 / 42 runsflaked over last 7 days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good!
What does this PR do?
Fixes #10106
Type of change
How should this be tested?
Mandatory Tasks
Checklist