Fixed a bug where it was possible to add the same user multiple times to a team
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user