model

package
v3.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrForbidden          = errors.New("forbidden access")
	ErrUnknownUser        = errors.New("unknown user")
	ErrMalformedContent   = errors.New("malformed content")
	ErrUnavailableService = errors.New("unavailable service")
	ErrInvalidCredentials = errors.New("invalid credentials")
)
View Source
var ErrUnknownUserKind = errors.New("unknown UserKind")
View Source
var UserKinds = sync.OnceValue(func() []UserKind {
	count := len(_UserKind_index) - 1
	values := make([]UserKind, count)

	for i := range count {
		values[i] = UserKind(i)
	}

	return values
})

Functions

func StoreUser

func StoreUser(ctx context.Context, user User) context.Context

Types

type Authentication added in v3.1.0

type Authentication interface {
	GetUser(context.Context, *http.Request) (User, error)
	OnUnauthorized(http.ResponseWriter, *http.Request, error)
}

type Authorization

type Authorization interface {
	IsAuthorized(context.Context, *http.Request, User) bool
	OnForbidden(http.ResponseWriter, *http.Request, User)
}

type Storage

type Storage interface {
	Create(context.Context, string) (User, error)
	Delete(context.Context, User) error
}

type User

type User struct {
	ID    string   `json:"id"`
	Name  string   `json:"name"`
	Image string   `json:"image"`
	Kind  UserKind `json:"kind"`
}

func NewUser

func NewUser(name string) User

func ReadUser

func ReadUser(ctx context.Context) (output User)

type UserKind added in v3.6.2

type UserKind int
const (
	Invite UserKind = iota
	GitHub
	Discord
	Basic
)

func ParseUserKind added in v3.6.2

func ParseUserKind(value string) (UserKind, error)

func (UserKind) MarshalJSON added in v3.6.2

func (e UserKind) MarshalJSON() ([]byte, error)

func (UserKind) String added in v3.6.2

func (i UserKind) String() string

func (*UserKind) UnmarshalJSON added in v3.6.2

func (e *UserKind) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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