Merge pull request #171 from cloudflare/kyle/usernames-in-error

Improve user names in delegation error.
This commit is contained in:
Zi Lin
2016-09-06 15:01:10 -07:00
committed by GitHub

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.