Fix updating team admin status
This commit is contained in:
parent
11722bf029
commit
6a82d4e2af
1 changed files with 5 additions and 3 deletions
|
@ -117,18 +117,20 @@ func (tm *TeamMember) Update() (err error) {
|
||||||
tm.UserID = user.ID
|
tm.UserID = user.ID
|
||||||
|
|
||||||
// Get the full member object and change the admin right
|
// Get the full member object and change the admin right
|
||||||
|
ttm := &TeamMember{}
|
||||||
_, err = x.
|
_, err = x.
|
||||||
Where("team_id = ? AND user_id = ?", tm.TeamID, tm.UserID).
|
Where("team_id = ? AND user_id = ?", tm.TeamID, tm.UserID).
|
||||||
Get(tm)
|
Get(ttm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tm.Admin = !tm.Admin
|
ttm.Admin = !ttm.Admin
|
||||||
|
|
||||||
// Do the update
|
// Do the update
|
||||||
_, err = x.
|
_, err = x.
|
||||||
Where("team_id = ? AND user_id = ?", tm.TeamID, tm.UserID).
|
Where("team_id = ? AND user_id = ?", tm.TeamID, tm.UserID).
|
||||||
Cols("admin").
|
Cols("admin").
|
||||||
Update(tm)
|
Update(ttm)
|
||||||
|
tm.Admin = ttm.Admin // Since we're returning the updated rights object
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue