token

package
v0.0.0-...-dc37515 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	// contains filtered or unexported fields
}

Token is a manager for the token entity.

func NewToken

func NewToken(logger logrus.FieldLogger, conn database.DB) *Token

NewToken creates a new manager for the token entity.

func NewTokenFromRequest

func NewTokenFromRequest(r *http.Request) *Token

NewTokenFromRequest returns the token manager from the request context.

func (*Token) Consume

func (t *Token) Consume(uuid uuid.UUID, category, token string) (bool, error)

Consume consumes an active (not expired) token that is linked to an uuid and a category.

func (*Token) Create

func (t *Token) Create(uuid uuid.UUID, category string, expires *time.Time) (string, error)

Create generates a token for a given uuid and category, with an optional expiration.

func (*Token) RemoveExpired

func (t *Token) RemoveExpired() error

RemoveExpired removes expired tokens from the database.

func (Token) SchemaSQL

func (t Token) SchemaSQL() string

SchemaSQL returns the schema for tokens.

Jump to

Keyboard shortcuts

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