diff --git a/service/user/user.go b/service/user/user.go index 582ab51a..88b2ada6 100644 --- a/service/user/user.go +++ b/service/user/user.go @@ -218,12 +218,16 @@ func DeleteUser(w http.ResponseWriter, currentUser *model.User, id string) (int, if db.ORM.First(&user, id).RecordNotFound() { return http.StatusNotFound, errors.New("user not found") } + if (user.ID == 0) { + return http.StatusInternalServerError, errors.New("You can't delete that!") + } if db.ORM.Delete(&user).Error != nil { return http.StatusInternalServerError, errors.New("user not deleted") } if userPermission.CurrentUserIdentical(currentUser, user.ID) { return ClearCookie(w) } + return http.StatusOK, nil } diff --git a/templates/admin/userlist.html b/templates/admin/userlist.html index db67a2d8..c3a29d9d 100644 --- a/templates/admin/userlist.html +++ b/templates/admin/userlist.html @@ -5,7 +5,7 @@