mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 16:45:35 +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, getRequestDateRange, getRequestFilters } from 'lib/request';
|
||||
import { badRequest, unauthorized, json } from 'lib/response';
|
||||
import { checkAuth, canViewWebsite } from 'lib/auth';
|
||||
import { parseRequest, getRequestDateRange, getRequestFilters } from 'lib/request';
|
||||
import { unauthorized, json } from 'lib/response';
|
||||
import { canViewWebsite } from 'lib/auth';
|
||||
import { getCompareDate } from 'lib/date';
|
||||
import { filterParams } from 'lib/schema';
|
||||
import { getWebsiteStats } from 'queries';
|
||||
|
|
@ -17,18 +17,16 @@ export async function GET(
|
|||
...filterParams,
|
||||
});
|
||||
|
||||
const { query, error } = await checkRequest(request, schema);
|
||||
const { auth, query, error } = await parseRequest(request, schema);
|
||||
|
||||
if (error) {
|
||||
return badRequest(error);
|
||||
return error();
|
||||
}
|
||||
|
||||
const { websiteId } = await params;
|
||||
const { compare } = query;
|
||||
|
||||
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