fleet/server/service/validation_invites.go
Victor Vrantchan 6fb96d98f7 Adds endpoints to invite new users to the application. (#235)
User service checks that tokens are valid on new user signups.
Closes #230
2016-09-28 22:44:05 -04:00

24 lines
625 B
Go

package service
import (
"github.com/kolide/kolide-ose/server/kolide"
"golang.org/x/net/context"
)
func (mw validationMiddleware) InviteNewUser(ctx context.Context, payload kolide.InvitePayload) (*kolide.Invite, error) {
invalid := &invalidArgumentError{}
if payload.Email == nil {
invalid.Append("email", "missing required argument")
}
if payload.InvitedBy == nil {
invalid.Append("invited_by", "missing required argument")
}
if payload.Admin == nil {
invalid.Append("admin", "missing required argument")
}
if invalid.HasErrors() {
return nil, invalid
}
return mw.Service.InviteNewUser(ctx, payload)
}