Fix updating team admin status

This commit is contained in:
kolaente 2020-08-05 17:28:11 +02:00
parent 11722bf029
commit 6a82d4e2af
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -117,18 +117,20 @@ func (tm *TeamMember) Update() (err error) {
tm.UserID = user.ID
// Get the full member object and change the admin right
ttm := &TeamMember{}
_, err = x.
Where("team_id = ? AND user_id = ?", tm.TeamID, tm.UserID).
Get(tm)
Get(ttm)
if err != nil {
return err
}
tm.Admin = !tm.Admin
ttm.Admin = !ttm.Admin
// Do the update
_, err = x.
Where("team_id = ? AND user_id = ?", tm.TeamID, tm.UserID).
Cols("admin").
Update(tm)
Update(ttm)
tm.Admin = ttm.Admin // Since we're returning the updated rights object
return
}