1
0

Fixed a bug where it was possible to add the same user multiple times to a team

This commit is contained in:
kolaente
2018-07-26 10:06:41 +02:00
parent 9c451daf30
commit 80e9021ba6
3 changed files with 26 additions and 0 deletions

View File

@ -14,6 +14,13 @@ func (tm *TeamMember) Create(doer *User) (err error) {
return
}
// Check if that user is already part of the team
exists, err := x.Where("team_id = ? AND user_id = ?", tm.TeamID, tm.UserID).
Get(&TeamMember{})
if exists {
return ErrUserIsMemberOfTeam{tm.TeamID, tm.UserID}
}
// Insert the user
_, err = x.Insert(tm)
return