Allow user to delete themselves
Previously users were prevented from removing themselves. Connect https://github.com/influxdata/chronograf/issues/2711pull/10616/head
parent
3bacff669d
commit
1890fd6b08
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue