diff --git a/pkg/controller/block/block.go b/pkg/controller/block/block.go index 297affc..232c4fb 100644 --- a/pkg/controller/block/block.go +++ b/pkg/controller/block/block.go @@ -1,10 +1,12 @@ package block import ( + "fmt" "net/http" "strings" "code.nonshy.com/nonshy/website/pkg/config" + "code.nonshy.com/nonshy/website/pkg/log" "code.nonshy.com/nonshy/website/pkg/models" "code.nonshy.com/nonshy/website/pkg/session" "code.nonshy.com/nonshy/website/pkg/templates" @@ -97,6 +99,24 @@ func BlockUser() http.HandlerFunc { // Can't block admins. if user.IsAdmin { + // For curiosity's sake, log a report. + fb := &models.Feedback{ + Intent: "report", + Subject: "A user tried to block an admin", + Message: fmt.Sprintf( + "A user has tried to block an admin user account!\n\n"+ + "* Username: %s\n* Tried to block: %s", + currentUser.Username, + user.Username, + ), + UserID: currentUser.ID, + TableName: "users", + TableID: currentUser.ID, + } + if err := models.CreateFeedback(fb); err != nil { + log.Error("Could not log feedback for user %s trying to block admin %s: %s", currentUser.Username, user.Username, err) + } + session.FlashError(w, r, "You can not block site administrators.") templates.Redirect(w, "/u/"+username) return