Add getAuthUser() auth guard to all data API routes (task 7.1)
Add 401 Unauthorized check at the top of every handler in: - /api/upload (POST) - /api/candles (GET) - /api/charts (GET) and /api/charts/[id] (GET, DELETE) - /api/annotations (GET, POST, DELETE) and /api/annotations/[id] (PATCH, DELETE) - /api/annotation-types (GET, POST, DELETE) and /api/annotation-types/[id] (PATCH) - /api/span-annotations (GET, POST, DELETE), /[id] (PATCH, DELETE), /export (GET) - /api/span-label-types (GET, POST) and /[id] (PATCH, DELETE) - /api/export (GET) and /api/export/spans (GET) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
aa2c5fdb69
commit
9901d0f3f1
16 changed files with 146 additions and 1 deletions
|
|
@ -2,8 +2,14 @@ import { NextRequest, NextResponse } from 'next/server';
|
|||
import { db } from '@/lib/db';
|
||||
import { candles, charts } from '@/lib/db/schema';
|
||||
import { asc, desc, eq } from 'drizzle-orm';
|
||||
import { getAuthUser } from '@/lib/auth';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const user = await getAuthUser();
|
||||
if (!user) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
try {
|
||||
const { searchParams } = request.nextUrl;
|
||||
let chartId = searchParams.get('chartId');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue