Documentation
¶
Overview ¶
Package invites manages single-use invite codes for beta sign-up.
Codes are 20-character URL-safe random strings generated by the admin. Each code may be redeemed exactly once; Redeem uses an UPDATE...WHERE used_at IS NULL so concurrent redemption attempts leave only one winner.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCode = errors.New("invite code invalid or already used")
ErrInvalidCode is returned when a code does not exist or has already been redeemed.
Functions ¶
This section is empty.
Types ¶
type Code ¶
type Code struct {
Code string
CreatedAt time.Time
UsedAt *time.Time
UsedBy *string // email of the user who redeemed it, nil if unused
}
Code is the public view of an invite_codes row.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps the invite_codes table.
func (*Store) Generate ¶
Generate creates count single-use invite codes owned by createdBy and returns the plaintext code strings.
func (*Store) List ¶
List returns all invite codes, most-recently-created first. usedBy is the email of the redeeming user when known.