Validation check for not removing the last account admin

This commit is contained in:
Torkel Ödegaard
2015-01-20 15:48:19 +01:00
parent 4ea5d80099
commit eec178458b
5 changed files with 28 additions and 3 deletions

View File

@ -54,6 +54,10 @@ func RemoveAccountUser(c *middleware.Context) {
cmd := m.RemoveAccountUserCommand{AccountId: c.AccountId, UserId: userId}
if err := bus.Dispatch(&cmd); err != nil {
if err == m.ErrLastAccountAdmin {
c.JsonApiErr(400, "Cannot remove last account admin", nil)
return
}
c.JsonApiErr(500, "Failed to remove user from account", err)
}