cursor update to magic link v.3
This commit is contained in:
@@ -11,7 +11,12 @@ import { audit } from "@/lib/audit-log";
|
||||
*
|
||||
* Query params:
|
||||
* - token: The magic link token
|
||||
* - destination: 'ticket' or 'dashboard' (optional, can be in token)
|
||||
* - destination: 'ticket', 'dashboard', or 'rsvp' (optional, can be in token)
|
||||
*
|
||||
* Destination behavior:
|
||||
* - 'rsvp': Always redirects to RSVP page (for invitation emails)
|
||||
* - 'ticket': Direct ticket access (for RSVP confirmation emails)
|
||||
* - 'dashboard': Dashboard if RSVP'd, otherwise RSVP page (for RSVP confirmation emails)
|
||||
*/
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
@@ -52,8 +57,22 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
// Determine destination - use ENV.APP_URL to ensure correct production domain
|
||||
const destination = tokenData.destination || "dashboard";
|
||||
const redirectUrl =
|
||||
destination === "ticket" ? `${ENV.APP_URL}/dashboard/ticket` : `${ENV.APP_URL}/dashboard`;
|
||||
let redirectUrl: string;
|
||||
|
||||
if (destination === "ticket") {
|
||||
// Direct ticket access (for RSVP confirmation email)
|
||||
redirectUrl = `${ENV.APP_URL}/dashboard/ticket`;
|
||||
} else if (destination === "rsvp") {
|
||||
// RSVP page (for invitation email - guest hasn't RSVP'd yet)
|
||||
redirectUrl = `${ENV.APP_URL}/rsvp?invitecode=${guest.inviteCode}`;
|
||||
} else {
|
||||
// Dashboard (default or for RSVP confirmation email)
|
||||
// If guest hasn't RSVP'd yet, redirect to RSVP page instead
|
||||
const hasRSVPd = guest.isAttending !== null && guest.isAttending !== undefined;
|
||||
redirectUrl = hasRSVPd
|
||||
? `${ENV.APP_URL}/dashboard`
|
||||
: `${ENV.APP_URL}/rsvp?invitecode=${guest.inviteCode}`;
|
||||
}
|
||||
|
||||
// Create redirect response
|
||||
let response = NextResponse.redirect(redirectUrl);
|
||||
|
||||
Reference in New Issue
Block a user