mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Merged auth into new parseRequest method.
This commit is contained in:
parent
e51f182403
commit
2d6428172b
39 changed files with 296 additions and 316 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { z } from 'zod';
|
||||
import { checkRequest } from 'lib/request';
|
||||
import { badRequest, unauthorized, json } from 'lib/response';
|
||||
import { canViewWebsite, checkAuth } from 'lib/auth';
|
||||
import { parseRequest } from 'lib/request';
|
||||
import { unauthorized, json } from 'lib/response';
|
||||
import { canViewWebsite } from 'lib/auth';
|
||||
import { getSessionDataProperties } from 'queries';
|
||||
|
||||
export async function GET(
|
||||
|
|
@ -14,18 +14,16 @@ export async function GET(
|
|||
propertyName: z.string().optional(),
|
||||
});
|
||||
|
||||
const { query, error } = await checkRequest(request, schema);
|
||||
const { auth, query, error } = await parseRequest(request, schema);
|
||||
|
||||
if (error) {
|
||||
return badRequest(error);
|
||||
return error();
|
||||
}
|
||||
|
||||
const { startAt, endAt, propertyName } = query;
|
||||
const { websiteId } = await params;
|
||||
|
||||
const auth = await checkAuth(request);
|
||||
|
||||
if (!auth || !(await canViewWebsite(auth, websiteId))) {
|
||||
if (!(await canViewWebsite(auth, websiteId))) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue