data

package
v0.0.0-...-db64729 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeAuthentication = "authentication"
)

Variables

View Source
var AnonymousUser = new(User)
View Source
var (
	ErrDuplicateUsername = errors.New("duplicate username")
)
View Source
var (
	ErrRecordNotFound = errors.New("record not found")
)

Functions

This section is empty.

Types

type Message

type Message struct {
	ID     uuid.UUID `json:"id"`
	Text   string    `json:"text"`
	SentAt time.Time `json:"sent_at"`
	Author User      `json:"author"`
}

type MessageModel

type MessageModel struct {
	DB *sql.DB
}

func (MessageModel) GetAll

func (m MessageModel) GetAll() ([]*Message, error)

func (MessageModel) Insert

func (m MessageModel) Insert(message *Message) error

type Models

type Models struct {
	Users    UserModel
	Messages MessageModel
	Tokens   TokenModel
}

func NewModels

func NewModels(db *sql.DB) Models

type Token

type Token struct {
	PlainText string    `json:"token"`
	Hash      []byte    `json:"-"`
	UserID    uuid.UUID `json:"-"`
	Expiry    time.Time `json:"expiry"`
	Scope     string    `json:"-"`
}

type TokenModel

type TokenModel struct {
	DB *sql.DB
}

func (TokenModel) DeleteForUser

func (m TokenModel) DeleteForUser(userID uuid.UUID, scope string) error

func (TokenModel) Insert

func (m TokenModel) Insert(token *Token) error

func (TokenModel) New

func (m TokenModel) New(userID uuid.UUID, ttl time.Duration, scope string) (*Token, error)

type User

type User struct {
	ID        uuid.UUID `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	Username  string    `json:"username"`
	Password  password  `json:"-"`
}

func (*User) IsAnonymous

func (u *User) IsAnonymous() bool

type UserModel

type UserModel struct {
	DB *sql.DB
}

func (*UserModel) GetByToken

func (m *UserModel) GetByToken(token string, scope string) (*User, error)

func (*UserModel) GetByUsername

func (m *UserModel) GetByUsername(username string) (*User, error)

func (UserModel) Insert

func (m UserModel) Insert(user *User) error

Jump to

Keyboard shortcuts

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