76aad8b1d1
Build pitch-deck / build-push-deploy (push) Successful in 1m31s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 32s
CI / test-python-voice (push) Successful in 34s
CI / test-bqas (push) Successful in 30s
- New pitch_short_links table stores 6-char alphanumeric codes mapped to magic link tokens - GET /p/[code] redirects to /auth/verify?token=... (302, validates expiry) - All magic link generation points (invite, generate-link, resend) now create a short code - Emails (invite + resend) use the short URL — less token-like, cleaner for spam filters - Copy-link UI shows short URL prominently with full URL as fallback - Migration 008 added to /api/admin/migrate Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 lines
666 B
TypeScript
22 lines
666 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import pool from '@/lib/db'
|
|
|
|
interface Ctx { params: Promise<{ code: string }> }
|
|
|
|
export async function GET(request: NextRequest, ctx: Ctx) {
|
|
const { code } = await ctx.params
|
|
|
|
const { rows } = await pool.query(
|
|
`SELECT sl.token FROM pitch_short_links sl
|
|
JOIN pitch_magic_links ml ON ml.token = sl.token
|
|
WHERE sl.short_code = $1 AND ml.expires_at > NOW()`,
|
|
[code.toLowerCase()],
|
|
)
|
|
|
|
if (rows.length === 0) {
|
|
return NextResponse.redirect(new URL('/auth?error=invalid', request.url))
|
|
}
|
|
|
|
return NextResponse.redirect(new URL(`/auth/verify?token=${rows[0].token}`, request.url))
|
|
}
|