model

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlacklistRecordNotFound = NewError("blacklist.record.not_found")
	ErrTokenNotFound           = NewError("token.not_found")

	ErrInvalidLimit  = NewError("query.invalid_limit")
	ErrInvalidOffset = NewError("query.invalid_offset")
)

Functions

func GenerateSecret added in v0.0.23

func GenerateSecret(length int) string

Types

type AuthStatus

type AuthStatus string

AuthStatus is status of authorization.

const (
	// AuthStatusSucceed represents successful authorization.
	AuthStatusSucceed AuthStatus = "succeed"
	// AuthStatusFailed represents failed authorization.
	AuthStatusFailed AuthStatus = "failed"
)

type Authorization

type Authorization struct {
	Token
	Status AuthStatus `json:"status"`
	Error  *string    `json:"error,omitempty"`
	IP     string     `json:"ip"`
	Time   time.Time  `json:"timestamp"`
}

Authorization represents authorization

type BlackListItem

type BlackListItem struct {
	IPv4    string `json:"ipv4" db:"ipv4"`
	Enabled bool   `json:"enabled" db:"enabled"`
}

BlackListItem is a domain model of blacklisted iterms.

type Error

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

func NewError

func NewError(text string) Error

func (Error) Error

func (e Error) Error() string

type Token

type Token struct {
	ID        string    `json:"id" db:"id"`
	UserID    string    `json:"user_id" db:"user_id"`
	Secret    string    `json:"secret,omitempty" db:"secret"`
	Name      string    `json:"name" db:"name"`
	Enabled   bool      `json:"enabled" db:"enabled"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

Token is a domain model of token.

func NewToken

func NewToken(userID, name string) *Token

func (*Token) ClearSecret added in v0.0.23

func (t *Token) ClearSecret()

func (*Token) ResetSecret

func (t *Token) ResetSecret()

type User

type User struct {
	ID string
}

type ValidationError

type ValidationError struct {
	Messages map[string][]string
}

func NewValidationError

func NewValidationError(messages map[string][]string) ValidationError

func (*ValidationError) Append

func (e *ValidationError) Append(field string, message ...string)

func (ValidationError) Error

func (e ValidationError) Error() string

func (ValidationError) WithPrefix

func (e ValidationError) WithPrefix(prefix string) ValidationError

Jump to

Keyboard shortcuts

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