From 59eac91639fb159732026d6ba9d1b9f66375d9f8 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Tue, 6 Sep 2016 13:51:55 -0700 Subject: [PATCH] Improve user names in delegation error. When delegating to a group of users, Red October will return the error "User not found" if the user can't be found. This makes it difficult to figure out the user that couldn't be found. This change goes through the list of users and includes all usernames that couldn't be found in the error message. --- core/core.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/core.go b/core/core.go index ac23c63..15f3bc6 100644 --- a/core/core.go +++ b/core/core.go @@ -10,6 +10,7 @@ import ( "fmt" "log" "strconv" + "strings" "time" "github.com/cloudflare/redoctober/config" @@ -302,7 +303,6 @@ func Create(jsonIn []byte) ([]byte, error) { // Summary processes a summary request. func Summary(jsonIn []byte) ([]byte, error) { - log.Println(string(jsonIn)) var s SummaryRequest var err error @@ -398,12 +398,18 @@ func Delegate(jsonIn []byte) ([]byte, error) { } // Make sure the user we are delegating to exists + var invalidUsers []string for _, user := range s.Users { if _, ok := records.GetRecord(user); !ok { - err = errors.New("User not present") - return jsonStatusError(err) + invalidUsers = append(invalidUsers, user) } } + + if len(invalidUsers) != 0 { + err = fmt.Errorf("User(s) not present: %s", strings.Join(invalidUsers, ", ")) + return jsonStatusError(err) + } + // Find password record for user and verify that their password // matches. If not found then add a new entry for this user.