diff options
author | Wendell Sun <iwendellsun@gmail.com> | 2018-02-23 16:42:02 +0800 |
---|---|---|
committer | Bo-Yi Wu <appleboy.tw@gmail.com> | 2018-02-23 16:42:02 +0800 |
commit | 2d1c5c3756beab3dfb3a1463d601385ab2e5db6f (patch) | |
tree | 29cd7ce0c420f2da0fbb372e686fe57960ebf9ad /models/org_team.go | |
parent | 19bf4ddf800dd405bddbafee7574ff4df07ed275 (diff) | |
download | gitea-2d1c5c3756beab3dfb3a1463d601385ab2e5db6f.tar.gz gitea-2d1c5c3756beab3dfb3a1463d601385ab2e5db6f.zip |
Fix remove team member issue (#3566)
Put sess.Commit() out of the RemoveOrgUser function
Add an empty line to separate import packages
Diffstat (limited to 'models/org_team.go')
-rw-r--r-- | models/org_team.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/models/org_team.go b/models/org_team.go index 941b7ed2a1..9d8a031418 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -10,6 +10,8 @@ import ( "strings" "code.gitea.io/gitea/modules/log" + + "github.com/go-xorm/xorm" ) const ownerTeamName = "Owners" @@ -521,7 +523,7 @@ func AddTeamMember(team *Team, userID int64) error { return sess.Commit() } -func removeTeamMember(e Engine, team *Team, userID int64) error { +func removeTeamMember(e *xorm.Session, team *Team, userID int64) error { isMember, err := isTeamMember(e, team.OrgID, team.ID, userID) if err != nil || !isMember { return err @@ -558,6 +560,16 @@ func removeTeamMember(e Engine, team *Team, userID int64) error { } } + // Check if the user is a member of any team in the organization. + if count, err := e.Count(&TeamUser{ + UID: userID, + OrgID: team.OrgID, + }); err != nil { + return err + } else if count == 0 { + return removeOrgUser(e, team.OrgID, userID) + } + return nil } |