mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
fix zod validations and prisma query for admin teams
This commit is contained in:
parent
df3ae72ab7
commit
9fb38f6970
3 changed files with 19 additions and 15 deletions
|
|
@ -24,22 +24,26 @@ export async function GET(request: Request) {
|
||||||
const teams = await getTeams(
|
const teams = await getTeams(
|
||||||
{
|
{
|
||||||
include: {
|
include: {
|
||||||
_count: {
|
|
||||||
select: {
|
|
||||||
members: true,
|
|
||||||
websites: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
members: {
|
members: {
|
||||||
select: {
|
include: {
|
||||||
user: {
|
user: {
|
||||||
omit: {
|
select: {
|
||||||
password: true,
|
id: true,
|
||||||
|
username: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
where: {
|
},
|
||||||
role: 'team-owner',
|
_count: {
|
||||||
|
select: {
|
||||||
|
websites: {
|
||||||
|
where: { deletedAt: null },
|
||||||
|
},
|
||||||
|
members: {
|
||||||
|
where: {
|
||||||
|
user: { deletedAt: null },
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { uuid } from '@/lib/crypto';
|
import { uuid } from '@/lib/crypto';
|
||||||
import { pagingParams, reportSchema } from '@/lib/schema';
|
import { pagingParams, reportSchema, reportTypeParam } from '@/lib/schema';
|
||||||
import { parseRequest } from '@/lib/request';
|
import { parseRequest } from '@/lib/request';
|
||||||
import { canViewWebsite, canUpdateWebsite } from '@/permissions';
|
import { canViewWebsite, canUpdateWebsite } from '@/permissions';
|
||||||
import { unauthorized, json } from '@/lib/response';
|
import { unauthorized, json } from '@/lib/response';
|
||||||
|
|
@ -9,7 +9,7 @@ import { getReports, createReport } from '@/queries/prisma';
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
websiteId: z.uuid(),
|
websiteId: z.uuid(),
|
||||||
type: z.string().optional(),
|
type: reportTypeParam.optional(),
|
||||||
...pagingParams,
|
...pagingParams,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ export async function GET(request: Request, { params }: { params: Promise<{ user
|
||||||
|
|
||||||
export async function POST(request: Request, { params }: { params: Promise<{ userId: string }> }) {
|
export async function POST(request: Request, { params }: { params: Promise<{ userId: string }> }) {
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
username: z.string().max(255),
|
username: z.string().max(255).optional(),
|
||||||
password: z.string().max(255).optional(),
|
password: z.string().max(255).optional(),
|
||||||
role: userRoleParam,
|
role: userRoleParam.optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { auth, body, error } = await parseRequest(request, schema);
|
const { auth, body, error } = await parseRequest(request, schema);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue