You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`/invite/invite-error?reason=email-not-verified&details=${encodeURIComponent(`You must verify your email address (${userData[0].email}) before accepting invitations.`)}`,
90
+
env.NEXT_PUBLIC_APP_URL||'https://sim.ai'
91
+
)
92
+
)
93
+
}
94
+
73
95
// Verify the email matches the current user
74
96
if(orgInvitation.email!==session.user.email){
75
97
returnNextResponse.redirect(
76
98
newURL(
77
-
'/invite/invite-error?reason=email-mismatch',
99
+
`/invite/invite-error?reason=email-mismatch&details=${encodeURIComponent(`Invitation was sent to ${orgInvitation.email}, but you're logged in as ${userData[0].email}`)}`,
78
100
env.NEXT_PUBLIC_APP_URL||'https://sim.ai'
79
101
)
80
102
)
@@ -235,6 +257,24 @@ export async function POST(req: NextRequest) {
`/invite/invite-error?reason=email-not-verified&details=${encodeURIComponent(`You must verify your email address (${userData.email}) before accepting invitations.`)}`,
// Check if the logged-in user's email matches the invitation
97
+
constisValidMatch=userEmail===invitationEmail
93
98
94
99
if(!isValidMatch){
95
-
// Get user info to include in the error message
96
-
constuserData=awaitdb
97
-
.select()
98
-
.from(user)
99
-
.where(eq(user.id,session.user.id))
100
-
.then((rows)=>rows[0])
101
-
102
100
returnNextResponse.redirect(
103
101
newURL(
104
-
`/invite/invite-error?reason=email-mismatch&details=${encodeURIComponent(`Invitation was sent to ${invitation.email}, but you're logged in as ${userData?.email||session.user.email}`)}`,
102
+
`/invite/invite-error?reason=email-mismatch&details=${encodeURIComponent(`Invitation was sent to ${invitation.email}, but you're logged in as ${userData.email}`)}`,
0 commit comments