mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
Fixed team website create.
This commit is contained in:
parent
e971f2533d
commit
d9670f10a4
8 changed files with 29 additions and 39 deletions
|
|
@ -1,12 +1,11 @@
|
|||
import * as yup from 'yup';
|
||||
import { canCreateTeamWebsite, canViewTeam } from 'lib/auth';
|
||||
import { canViewTeam } from 'lib/auth';
|
||||
import { useAuth, useValidate } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody, SearchFilter } from 'lib/types';
|
||||
import { pageInfo } from 'lib/schema';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { createWebsite, getTeamWebsites } from 'queries';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { ok, unauthorized } from 'next-basics';
|
||||
import { getTeamWebsites } from 'queries';
|
||||
|
||||
export interface TeamWebsiteRequestQuery extends SearchFilter {
|
||||
teamId: string;
|
||||
|
|
@ -54,18 +53,4 @@ export default async (
|
|||
|
||||
return ok(res, websites);
|
||||
}
|
||||
|
||||
if (req.method === 'POST') {
|
||||
if (!(await canCreateTeamWebsite(req.auth, teamId))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const { name, domain, shareId } = req.body;
|
||||
|
||||
const website = await createWebsite({ id: uuid(), name, domain, shareId });
|
||||
|
||||
return ok(res, website);
|
||||
}
|
||||
|
||||
return methodNotAllowed(res);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue