Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Merge branch 'main' into partner-identity-sync

Pedro Ladeiraeacd8e86b742
diff --cc apps/web/app/app.dub.co/(auth)/auth/confirm-email-change/[token]/page.tsx
index 63353fe27a,33604ccfc7..bf31dd87e2
--- a/apps/web/app/app.dub.co/(auth)/auth/confirm-email-change/[token]/page.tsx
+++ b/apps/web/app/app.dub.co/(auth)/auth/confirm-email-change/[token]/page.tsx
@@@ -76,42 -75,22 +76,52 @@@ const VerifyEmailChange = async ({ para
redirect(`/login?next=/auth/confirm-email-change/${token}`);
}
- const { id: userId, defaultPartnerId: partnerId } = session.user;
+ const { id: userId } = session.user;
+ const tokenIdentifier = tokenFound.identifier;
- const identifier = tokenFound.identifier.startsWith("pn_")
- ? partnerId
- : userId;
+ if (tokenIdentifier.startsWith("pn_")) {
+ const partnerUser = await prisma.partnerUser.findUnique({
+ where: {
+ userId_partnerId: {
+ userId,
+ partnerId: tokenIdentifier,
+ },
+ },
+ select: { role: true },
+ });
+
+ if (
+ !partnerUser ||
+ !hasPermission(partnerUser.role, "partner_profile.update")
+ ) {
+ return (
+ <EmptyState
+ icon={InputPassword}
+ title="Invalid Token"
+ description="This token is invalid. Please request a new one."
+ />
+ );
+ }
+ } else if (tokenIdentifier !== userId) {
+ return (
+ <EmptyState
+ icon={InputPassword}
+ title="Invalid Token"
+ description="This token is invalid. Please request a new one."
+ />
+ );
+ }
+ if (tokenFound.identifier !== identifier) {
+ return (
+ <EmptyState
+ icon={InputPassword}
+ title="Invalid Token"
+ description="This token is invalid or expired. Please request a new one."
+ />
+ );
+ }
+
const data = await redis.get<{
email: string;
newEmail: string;