db

package
v0.0.0-...-c160ba3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const LeaseSize = uint64(1000)

Variables

View Source
var (
	UsersID      = []byte("/u/i/")
	UsersEmail   = []byte("/u/e/")
	SiteSession  = []byte("/s/s/")
	SessionLease = []byte("/s/l/")
	SiteHash     = []byte("/s/h/")
	Domains      = []byte("/d/")
)

Functions

func CreateSessionFromEvent

func CreateSessionFromEvent(ctx context.Context, s *models.Session, event *models.Event) error

func CreateUser

func CreateUser(ctx context.Context, usr *models.UserData) (id uuid.UUID, err error)

func DeleteUser

func DeleteUser(ctx context.Context, id uuid.UUID) error

func GenerateUserID

func GenerateUserID(ctx context.Context, remoteIP, userAgent, domain, hostname string) (id uint64, err error)

func GetAndVerifyUserByEmail

func GetAndVerifyUserByEmail(ctx context.Context, email, password string) (*models.User, error)

func GetSessionID

func GetSessionID(ctx context.Context) (uint64, error)

func GetStore

func GetStore(ctx context.Context) *badger.DB

func GetUserByDomain

func GetUserByDomain(ctx context.Context, domain string) (*models.User, error)

func GetUserByEmail

func GetUserByEmail(ctx context.Context, email string) (*models.User, error)

func GetUserByID

func GetUserByID(ctx context.Context, id uuid.UUID) (*models.User, error)

func IsNotFound

func IsNotFound(err error) bool

func SaveSession

func SaveSession(ctx context.Context, event *models.Event, sessionWindow time.Duration) (ss *models.Session, err error)

func Session

func Session(ctx context.Context)

func Set

func Set(ctx context.Context, value []byte, keys ...*Key) error

func SetStore

func SetStore(ctx context.Context, s *badger.DB) context.Context

func UpdateUser

func UpdateUser(ctx context.Context, u *models.User) error

Types

type Key

type Key struct {
	bytes.Buffer
}

func UserKeys

func UserKeys(u *models.User) (keys []*Key)

func (*Key) Domain

func (k *Key) Domain(domain string) *Key

func (*Key) Hash

func (k *Key) Hash() *Key

func (*Key) SessionID

func (k *Key) SessionID(userID uint64, domain string) *Key

func (*Key) UserEmail

func (k *Key) UserEmail(email string) *Key

func (*Key) UserID

func (k *Key) UserID(id []byte) *Key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL