mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 07:07:17 +01:00
Open /websites endpoint to view all.
This commit is contained in:
parent
b314cc88f5
commit
467790b67a
3 changed files with 31 additions and 3 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import { canCreateWebsite } from 'lib/auth';
|
||||
import { canCreateWebsite, canViewAllWebsite } from 'lib/auth';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { useAuth, useCors, useValidate } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody, SearchFilter } from 'lib/types';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { createWebsite } from 'queries';
|
||||
import { createWebsite, getWebsites } from 'queries';
|
||||
import userWebsites from 'pages/api/users/[id]/websites';
|
||||
import * as yup from 'yup';
|
||||
import { pageInfo } from 'lib/schema';
|
||||
|
|
@ -41,6 +41,30 @@ export default async (
|
|||
} = req.auth;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
if (canViewAllWebsite(req.auth)) {
|
||||
const websites = getWebsites(req.query, {
|
||||
include: {
|
||||
teamWebsite: {
|
||||
include: {
|
||||
team: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
user: {
|
||||
select: {
|
||||
username: true,
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return ok(res, websites);
|
||||
}
|
||||
|
||||
if (!req.query.id) {
|
||||
req.query.id = userId;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue