mirror of
https://github.com/umami-software/umami.git
synced 2026-02-13 17:15:37 +01:00
Fix isAdmin check. Fix Schema.
This commit is contained in:
parent
371425ab60
commit
d60ad1c782
4 changed files with 18 additions and 18 deletions
|
|
@ -5,6 +5,8 @@ import { useAuth, useCors } from 'lib/middleware';
|
|||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok } from 'next-basics';
|
||||
import { createWebsite, getAllWebsites, getWebsitesByUserId } from 'queries';
|
||||
import { checkPermission } from 'lib/auth';
|
||||
import { UmamiApi } from 'lib/constants';
|
||||
|
||||
export interface WebsitesRequestQuery {
|
||||
include_all?: boolean;
|
||||
|
|
@ -25,12 +27,14 @@ export default async (
|
|||
await useAuth(req, res);
|
||||
|
||||
const {
|
||||
user: { id: userId, isAdmin },
|
||||
user: { id: userId },
|
||||
} = req.auth;
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { include_all } = req.query;
|
||||
|
||||
const isAdmin = await checkPermission(req, UmamiApi.Permission.Admin);
|
||||
|
||||
const websites =
|
||||
isAdmin && include_all ? await getAllWebsites() : await getWebsitesByUserId(userId);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue