Skip to content

Commit 0256081

Browse files
authored
ref(cells): Organization invites go the correct org scoped routes (#112137)
Updates get_invite_link to generate org-scoped invite URLs (/accept/<org_slug>/<member_id>/<token>/) instead of the legacy no-org format (/accept/<member_id>/<token>/). This is a prerequisite for removing the legacy no-org invite route and ensuring this works even when multiple cells are configured.
1 parent 28bd01a commit 0256081

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

fixtures/emails/invitation.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Your teammates at Example are using Sentry to catch errors, crush latency issues
44

55
Looks like they need your help. You've been invited to join them:
66

7-
http://testserver/accept/1/None/
7+
http://testserver/accept/example/1/None/
88

99
Heads up: this invite link is just for you. Don't share it unless you want random strangers fixing your bugs.
1010

src/sentry/api/endpoints/accept_organization_invite.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,14 @@ def get(
204204
# When SSO is required do *not* set a next_url to return to accept
205205
# invite. The invite will be accepted after SSO is completed.
206206
url = (
207-
reverse("sentry-accept-invite", args=[member_id, token])
207+
reverse(
208+
"sentry-organization-accept-invite",
209+
kwargs={
210+
"organization_slug": invite_context.organization.slug,
211+
"member_id": member_id,
212+
"token": token,
213+
},
214+
)
208215
if not auth_provider
209216
else "/"
210217
)

src/sentry/models/organizationmember.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ def get_invite_link(self, referrer: str | None = None):
334334
if not self.is_pending or not self.invite_approved:
335335
return None
336336
path = reverse(
337-
"sentry-accept-invite",
337+
"sentry-organization-accept-invite",
338338
kwargs={
339+
"organization_slug": self.organization.slug,
339340
"member_id": self.id,
340341
"token": self.token or self.legacy_token,
341342
},

src/sentry/web/frontend/debug/mail.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,12 @@ def invitation(request):
672672
"organization": org,
673673
"url": absolute_uri(
674674
reverse(
675-
"sentry-accept-invite",
676-
kwargs={"member_id": om.id, "token": om.token},
675+
"sentry-organization-accept-invite",
676+
kwargs={
677+
"organization_slug": org.slug,
678+
"member_id": om.id,
679+
"token": om.token,
680+
},
677681
)
678682
),
679683
},

tests/sentry/core/endpoints/test_organization_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,7 @@ def setUp(self) -> None:
22342234
assert self.has_2fa.has_2fa()
22352235

22362236
def assert_2fa_email_equal(self, outbox, expected):
2237-
invite_url_regex = re.compile(r"http://.*/accept/[0-9]+/[a-f0-9]+/")
2237+
invite_url_regex = re.compile(r"http://.*/accept/[^/]+/[0-9]+/[a-f0-9]+/")
22382238
assert len(outbox) == len(expected)
22392239
assert sorted(email.to[0] for email in outbox) == sorted(expected)
22402240
for email in outbox:

0 commit comments

Comments
 (0)