teams: editor/viewer team admin cant remove the last admin.

This commit is contained in:
Leonard Gram
2019-03-13 10:11:53 +01:00
parent 246e128048
commit c420af16b1
4 changed files with 33 additions and 6 deletions

View File

@ -271,6 +271,18 @@ func UpdateTeamMember(cmd *m.UpdateTeamMemberCommand) error {
return m.ErrTeamMemberNotFound
}
if cmd.ProtectLastAdmin {
lastAdmin, err := isLastAdmin(sess, cmd.OrgId, cmd.TeamId, cmd.UserId)
if err != nil {
return err
}
if lastAdmin {
return m.ErrLastTeamAdmin
}
}
if cmd.Permission != m.PERMISSION_ADMIN {
cmd.Permission = 0
}