Fixed uuid references in schemas.
This commit is contained in:
@@ -19,8 +19,14 @@ export function checkPassword(password: string, passwordHash: string) {
|
||||
return bcrypt.compareSync(password, passwordHash);
|
||||
}
|
||||
|
||||
export function getBearerToken(request: Request) {
|
||||
const auth = request.headers.get('authorization');
|
||||
|
||||
return auth?.split(' ')[1];
|
||||
}
|
||||
|
||||
export async function checkAuth(request: Request) {
|
||||
const token = request.headers.get('authorization')?.split(' ')?.[1];
|
||||
const token = getBearerToken(request);
|
||||
const payload = parseSecureToken(token, secret());
|
||||
const shareToken = await parseShareToken(request.headers);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { z } from 'zod';
|
||||
import { checkAuth } from '@/lib/auth';
|
||||
import { DEFAULT_PAGE_SIZE, FILTER_COLUMNS } from '@/lib/constants';
|
||||
import { getAllowedUnits, getMinimumUnit, maxDate, parseDateRange } from '@/lib/date';
|
||||
@@ -5,7 +6,6 @@ import { fetchWebsite } from '@/lib/load';
|
||||
import { badRequest, unauthorized } from '@/lib/response';
|
||||
import { QueryFilters } from '@/lib/types';
|
||||
import { getWebsiteSegment } from '@/queries';
|
||||
import { z } from 'zod/v4';
|
||||
import { filtersArrayToObject } from '@/lib/params';
|
||||
|
||||
export async function parseRequest(
|
||||
|
||||
@@ -35,8 +35,8 @@ export const filterParams = {
|
||||
hostname: z.string().optional(),
|
||||
language: z.string().optional(),
|
||||
event: z.string().optional(),
|
||||
segment: z.string().uuid().optional(),
|
||||
cohort: z.string().uuid().optional(),
|
||||
segment: z.uuid().optional(),
|
||||
cohort: z.uuid().optional(),
|
||||
eventType: z.coerce.number().int().positive().optional(),
|
||||
};
|
||||
|
||||
@@ -198,7 +198,7 @@ export const breakdownReportSchema = z.object({
|
||||
});
|
||||
|
||||
export const reportBaseSchema = z.object({
|
||||
websiteId: z.string().uuid(),
|
||||
websiteId: z.uuid(),
|
||||
type: reportTypeParam,
|
||||
name: z.string().max(200),
|
||||
description: z.string().max(500).optional(),
|
||||
@@ -220,7 +220,7 @@ export const reportSchema = reportBaseSchema;
|
||||
|
||||
export const reportResultSchema = z.intersection(
|
||||
z.object({
|
||||
websiteId: z.string().uuid(),
|
||||
websiteId: z.uuid(),
|
||||
filters: z.object({ ...filterParams }),
|
||||
}),
|
||||
reportTypeSchema,
|
||||
|
||||
Reference in New Issue
Block a user