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.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.go')
-rw-r--r-- | models/org.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/models/org.go b/models/org.go index 095265a12e..ed0d583067 100644 --- a/models/org.go +++ b/models/org.go @@ -436,8 +436,7 @@ func AddOrgUser(orgID, uid int64) error { return sess.Commit() } -// RemoveOrgUser removes user from given organization. -func RemoveOrgUser(orgID, userID int64) error { +func removeOrgUser(sess *xorm.Session, orgID, userID int64) error { ou := new(OrgUser) has, err := x. @@ -473,12 +472,6 @@ func RemoveOrgUser(orgID, userID int64) error { } } - sess := x.NewSession() - defer sess.Close() - if err := sess.Begin(); err != nil { - return err - } - if _, err := sess.ID(ou.ID).Delete(ou); err != nil { return err } else if _, err = sess.Exec("UPDATE `user` SET num_members=num_members-1 WHERE id=?", orgID); err != nil { @@ -520,6 +513,19 @@ func RemoveOrgUser(orgID, userID int64) error { } } + return nil +} + +// RemoveOrgUser removes user from given organization. +func RemoveOrgUser(orgID, userID int64) error { + sess := x.NewSession() + defer sess.Close() + if err := sess.Begin(); err != nil { + return err + } + if err := removeOrgUser(sess, orgID, userID); err != nil { + return err + } return sess.Commit() } |