From ceb9e039f1f217e1de97bda8ccfd0d8275b8f6d6 Mon Sep 17 00:00:00 2001 From: akuma06 Date: Wed, 10 May 2017 22:55:44 +0200 Subject: [PATCH] Renchon can't be deleted! --- service/user/user.go | 4 ++++ templates/admin/userlist.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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 @@ {{ .Username }} -{{ T "delete" }} +{{if .ID > 0}}{{ T "delete" }}{{end}} {{end}}