ensure email and passwords are set during setup (#1786)

This commit is contained in:
Thordur Bjornsson 2018-05-17 16:29:04 +02:00 committed by Mike Arpaia
parent 929000ba28
commit 6a4d50c7a6
2 changed files with 15 additions and 0 deletions

View File

@ -49,6 +49,12 @@ func setupCommand() cli.Command {
return err
}
if flEmail == "" {
return errors.Errorf("Email of the admin user to create must be provided")
}
if flPassword == "" {
return errors.Errorf("Password for the admin user to create must be provided")
}
token, err := fleet.Setup(flEmail, flPassword, flOrgName)
if err != nil {
switch err.(type) {

View File

@ -5,6 +5,7 @@ import (
"github.com/go-kit/kit/endpoint"
"github.com/kolide/fleet/server/kolide"
"github.com/pkg/errors"
)
type setupRequest struct {
@ -51,6 +52,14 @@ func makeSetupEndpoint(svc kolide.Service) endpoint.Endpoint {
// creating the user should be the last action. If there's a user
// present and other errors occur, the setup endpoint closes.
if req.Admin != nil {
if *req.Admin.Email == "" {
err := errors.Errorf("admin email cannot be empty")
return setupResponse{Err: err}, nil
}
if *req.Admin.Password == "" {
err := errors.Errorf("admin password cannot be empty")
return setupResponse{Err: err}, nil
}
admin, err = svc.NewAdminCreatedUser(ctx, *req.Admin)
if err != nil {
return setupResponse{Err: err}, nil