mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Fix joining team dupe. Add loading to team member remove. Fix messages.
This commit is contained in:
parent
a22d50a597
commit
6d5aeb3bd1
7 changed files with 90 additions and 11 deletions
|
|
@ -3,7 +3,7 @@ import { NextApiRequestQueryBody } from 'lib/types';
|
|||
import { useAuth } from 'lib/middleware';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, notFound } from 'next-basics';
|
||||
import { createTeamUser, getTeam } from 'queries';
|
||||
import { createTeamUser, getTeam, getTeamUser } from 'queries';
|
||||
import { ROLES } from 'lib/constants';
|
||||
|
||||
export interface TeamsJoinRequestBody {
|
||||
|
|
@ -25,6 +25,12 @@ export default async (
|
|||
return notFound(res, 'message.team-not-found');
|
||||
}
|
||||
|
||||
const teamUser = await getTeamUser(team.id, req.auth.user.id);
|
||||
|
||||
if (teamUser) {
|
||||
return methodNotAllowed(res, 'message.team-already-member');
|
||||
}
|
||||
|
||||
await createTeamUser(req.auth.user.id, team.id, ROLES.teamMember);
|
||||
|
||||
return ok(res, team);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue