mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +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 { unauthorized, json, badRequest, notFound } from 'lib/response';
|
||||
import { canCreateTeam, checkAuth } from 'lib/auth';
|
||||
import { checkRequest } from 'lib/request';
|
||||
import { canCreateTeam } from 'lib/auth';
|
||||
import { parseRequest } from 'lib/request';
|
||||
import { ROLES } from 'lib/constants';
|
||||
import { createTeamUser, findTeam, getTeamUser } from 'queries';
|
||||
|
||||
|
|
@ -10,15 +10,13 @@ export async function POST(request: Request) {
|
|||
accessCode: z.string().max(50),
|
||||
});
|
||||
|
||||
const { body, error } = await checkRequest(request, schema);
|
||||
const { auth, body, error } = await parseRequest(request, schema);
|
||||
|
||||
if (error) {
|
||||
return badRequest(error);
|
||||
return error();
|
||||
}
|
||||
|
||||
const auth = await checkAuth(request);
|
||||
|
||||
if (!auth || !(await canCreateTeam(auth))) {
|
||||
if (!(await canCreateTeam(auth))) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue