Skip to content

Commit b98609c

Browse files
authored
Merge pull request #138 from HackRU/137-bug-create-endpoint-allows-a-team-to-be-created-with-themselves
Bug: Team Creation allows self
2 parents 2f4ad89 + b086367 commit b98609c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/functions/teams/create/handler.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ const teamsCreate: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (ev
9898

9999
// Validate all member emails exist using user-exists logic
100100
const memberEmails = event.body.members.map((email) => email.toLowerCase());
101+
102+
// Check if user is trying to invite themselves
103+
if (memberEmails.includes(event.body.auth_email.toLowerCase())) {
104+
return {
105+
statusCode: 400,
106+
body: JSON.stringify({
107+
statusCode: 400,
108+
message: 'You cannot invite yourself to a team',
109+
}),
110+
};
111+
}
112+
101113
const invalidEmails = [];
102114
const emailsAlreadyInTeams = [];
103115

0 commit comments

Comments
 (0)