fix: don't allow to remove root user

This commit is contained in:
Oleg Lobanov
2021-01-11 22:33:36 +01:00
parent 8cea2f75b3
commit 019ce80fc5
6 changed files with 22 additions and 11 deletions

View File

@@ -99,8 +99,8 @@ var userGetHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request
var userDeleteHandler = withSelfOrAdmin(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
err := d.store.Users.Delete(d.raw.(uint))
if err == errors.ErrNotExist {
return http.StatusNotFound, err
if err != nil {
return errToStatus(err), err
}
return http.StatusOK, nil