package auth

import (
	"errors"
	"time"

	"code.secondbit.org/uuid"
)

var (
	// ErrNoSessionStore is returned when a Context tries to act on a sessionStore without setting on first.
	ErrNoSessionStore = errors.New("no sessionStore was specified for the Context")
	// ErrSessionNotFound is returned when a Session is requested but not found in the sessionStore.
	ErrSessionNotFound = errors.New("session not found in sessionStore")
	// ErrInvalidSession is returned when a Session is specified but is not valid.
	ErrInvalidSession = errors.New("session is not valid")
)

// Session represents a user's authenticated session, associating it with a profile
// and some audit data.
type Session struct {
	ID        string
	IP        string
	UserAgent string
	ProfileID uuid.ID
	Created   time.Time
	Login     string
	Active    bool
}

type sessionStore interface {
	createSession(session Session) error
	getSession(id string) (Session, error)
	removeSession(id string) error
	listSessions(profile uuid.ID, before time.Time, num int64) ([]Session, error)
}
