Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(user): users should not be able to join a team when created another one #89

Merged
merged 2 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/controllers/teams/acceptRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default [
const { userId } = request.params;
const askingUser = await fetchUser(userId);

if (askingUser.teamId) return forbidden(response, Error.AlreadyInTeam);

const { team } = getRequestInfo(response);
const tournament = await fetchTournament(team.tournamentId);

Expand Down
3 changes: 3 additions & 0 deletions src/operations/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export const createTeam = async (
},
},
},
askingTeam: {
disconnect: true,
},
type: userType,
},

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const enum Error {
TeamNotFull = "L'équipe est incomplète",
TeamFull = "L'équipe est complète",
AlreadyInTeam = "Tu es déjà dans l'équipe",
PlayerAlreadyInTeam = "L'utilisateur a déjà rejoint une équipe",
AlreadyAskedATeam = "Tu as déjà demandé de t'inscrire dans une équipe",
AlreadyCaptain = 'Tu es déjà un capitaine',
NotAskedTeam = "Tu ne demandes pas l'accès à l'équipe",
Expand Down