mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Hook up teamMemberDelete and teamDelete.
This commit is contained in:
parent
c3426a67ee
commit
701bde53b7
7 changed files with 150 additions and 21 deletions
28
pages/api/teamUsers/[id].ts
Normal file
28
pages/api/teamUsers/[id].ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { canDeleteTeamUser } from 'lib/auth';
|
||||
import { useAuth } from 'lib/middleware';
|
||||
import { NextApiRequestQueryBody } from 'lib/types';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { deleteTeamUser } from 'queries/admin/teamUser';
|
||||
|
||||
export interface TeamUserRequestQuery {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export default async (req: NextApiRequestQueryBody<TeamUserRequestQuery>, res: NextApiResponse) => {
|
||||
await useAuth(req, res);
|
||||
|
||||
const { id: teamUserId } = req.query;
|
||||
|
||||
if (req.method === 'DELETE') {
|
||||
if (!(await canDeleteTeamUser(req.auth, teamUserId))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const websites = await deleteTeamUser(teamUserId);
|
||||
|
||||
return ok(res, websites);
|
||||
}
|
||||
|
||||
return methodNotAllowed(res);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue