Skip to content

Commit c129653

Browse files
authored
Merge pull request #139 from HackRU/dev
Dev
2 parents 08954f6 + b98609c commit c129653

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)