|
|
|
@ -102,21 +102,23 @@ func updateOrgUserHelper(cmd m.UpdateOrgUserCommand) Response { |
|
|
|
|
|
|
|
|
|
// DELETE /api/org/users/:userId
|
|
|
|
|
func RemoveOrgUserForCurrentOrg(c *m.ReqContext) Response { |
|
|
|
|
userID := c.ParamsInt64(":userId") |
|
|
|
|
return removeOrgUserHelper(c.OrgId, userID) |
|
|
|
|
return removeOrgUserHelper(&m.RemoveOrgUserCommand{ |
|
|
|
|
UserId: c.ParamsInt64(":userId"), |
|
|
|
|
OrgId: c.OrgId, |
|
|
|
|
ShouldDeleteOrphanedUser: true, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// DELETE /api/orgs/:orgId/users/:userId
|
|
|
|
|
func RemoveOrgUser(c *m.ReqContext) Response { |
|
|
|
|
userID := c.ParamsInt64(":userId") |
|
|
|
|
orgID := c.ParamsInt64(":orgId") |
|
|
|
|
return removeOrgUserHelper(orgID, userID) |
|
|
|
|
return removeOrgUserHelper(&m.RemoveOrgUserCommand{ |
|
|
|
|
UserId: c.ParamsInt64(":userId"), |
|
|
|
|
OrgId: c.ParamsInt64(":orgId"), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func removeOrgUserHelper(orgID int64, userID int64) Response { |
|
|
|
|
cmd := m.RemoveOrgUserCommand{OrgId: orgID, UserId: userID} |
|
|
|
|
|
|
|
|
|
if err := bus.Dispatch(&cmd); err != nil { |
|
|
|
|
func removeOrgUserHelper(cmd *m.RemoveOrgUserCommand) Response { |
|
|
|
|
if err := bus.Dispatch(cmd); err != nil { |
|
|
|
|
if err == m.ErrLastOrgAdmin { |
|
|
|
|
return Error(400, "Cannot remove last organization admin", nil) |
|
|
|
|
} |
|
|
|
|