2016-09-29 02:44:05 +00:00
|
|
|
package kolide
|
|
|
|
|
|
|
|
import (
|
2017-03-15 15:55:30 +00:00
|
|
|
"context"
|
2016-09-29 02:44:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// InviteStore contains the methods for
|
|
|
|
// managing user invites in a datastore.
|
|
|
|
type InviteStore interface {
|
|
|
|
// NewInvite creates and stores a new invitation in a DB.
|
|
|
|
NewInvite(i *Invite) (*Invite, error)
|
|
|
|
|
|
|
|
// Invites lists all invites in the datastore.
|
2016-10-14 15:59:27 +00:00
|
|
|
ListInvites(opt ListOptions) ([]*Invite, error)
|
2016-09-29 02:44:05 +00:00
|
|
|
|
|
|
|
// Invite retrieves an invite by it's ID.
|
|
|
|
Invite(id uint) (*Invite, error)
|
|
|
|
|
|
|
|
// InviteByEmail retrieves an invite for a specific email address.
|
|
|
|
InviteByEmail(email string) (*Invite, error)
|
|
|
|
|
2016-12-30 01:58:12 +00:00
|
|
|
// InviteByToken retrieves and invite using the token string.
|
|
|
|
InviteByToken(token string) (*Invite, error)
|
|
|
|
|
2016-09-29 02:44:05 +00:00
|
|
|
// SaveInvite saves an invitation in the datastore.
|
|
|
|
SaveInvite(i *Invite) error
|
|
|
|
|
|
|
|
// DeleteInvite deletes an invitation.
|
2017-01-04 18:18:21 +00:00
|
|
|
DeleteInvite(id uint) error
|
2016-09-29 02:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// InviteService contains methods for a service which deals with
|
|
|
|
// user invites.
|
|
|
|
type InviteService interface {
|
2019-01-24 17:39:32 +00:00
|
|
|
// InviteNewUser creates an invite for a new user to join Fleet.
|
2016-09-29 02:44:05 +00:00
|
|
|
InviteNewUser(ctx context.Context, payload InvitePayload) (invite *Invite, err error)
|
|
|
|
|
|
|
|
// DeleteInvite removes an invite.
|
|
|
|
DeleteInvite(ctx context.Context, id uint) (err error)
|
|
|
|
|
|
|
|
// Invites returns a list of all invites.
|
2016-10-13 18:21:47 +00:00
|
|
|
ListInvites(ctx context.Context, opt ListOptions) (invites []*Invite, err error)
|
2016-09-29 02:44:05 +00:00
|
|
|
|
|
|
|
// VerifyInvite verifies that an invite exists and that it matches the
|
|
|
|
// invite token.
|
2016-12-30 01:58:12 +00:00
|
|
|
VerifyInvite(ctx context.Context, token string) (invite *Invite, err error)
|
2016-09-29 02:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// InvitePayload contains fields required to create a new user invite.
|
|
|
|
type InvitePayload struct {
|
2017-05-10 16:26:05 +00:00
|
|
|
InvitedBy *uint `json:"invited_by"`
|
|
|
|
Email *string
|
|
|
|
Admin *bool
|
|
|
|
Name *string
|
|
|
|
Position *string
|
|
|
|
SSOEnabled *bool `json:"sso_enabled"`
|
2016-09-29 02:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 17:39:32 +00:00
|
|
|
// Invite represents an invitation for a user to join Fleet.
|
2016-09-29 02:44:05 +00:00
|
|
|
type Invite struct {
|
2016-11-16 13:47:49 +00:00
|
|
|
UpdateCreateTimestamps
|
2017-05-10 16:26:05 +00:00
|
|
|
ID uint `json:"id"`
|
|
|
|
InvitedBy uint `json:"invited_by" db:"invited_by"`
|
|
|
|
Email string `json:"email"`
|
|
|
|
Admin bool `json:"admin"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Position string `json:"position,omitempty"`
|
|
|
|
Token string `json:"-"`
|
|
|
|
SSOEnabled bool `json:"sso_enabled" db:"sso_enabled"`
|
2016-09-29 02:44:05 +00:00
|
|
|
}
|