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.
This commit is contained in:
Kyle Isom
2016-09-06 13:51:55 -07:00
parent 4f560dbd0c
commit 59eac91639
+9 -3
View File
@@ -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.