Allow user to delete themselves

Previously users were prevented from removing themselves.

Connect https://github.com/influxdata/chronograf/issues/2711
pull/10616/head
Michael Desa 2018-02-07 09:46:08 -05:00
parent 3bacff669d
commit 1890fd6b08
2 changed files with 2 additions and 11 deletions

View File

@ -225,15 +225,6 @@ func (s *Service) RemoveUser(w http.ResponseWriter, r *http.Request) {
Error(w, http.StatusNotFound, err.Error(), s.Logger)
return
}
ctxUser, ok := hasUserContext(ctx)
if !ok {
Error(w, http.StatusBadRequest, "failed to retrieve user from context", s.Logger)
return
}
if ctxUser.ID == u.ID {
Error(w, http.StatusForbidden, "user cannot delete themselves", s.Logger)
return
}
if err := s.Store.Users(ctx).Delete(ctx, u); err != nil {
Error(w, http.StatusBadRequest, err.Error(), s.Logger)
return

View File

@ -663,8 +663,8 @@ func TestService_RemoveUser(t *testing.T) {
},
id: "1339",
},
wantStatus: http.StatusForbidden,
wantBody: `{"code":403,"message":"user cannot delete themselves"}`,
wantStatus: http.StatusNoContent,
wantBody: ``,
},
}
for _, tt := range tests {