model

package
v3.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 11 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.ResponseWriter, *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 DiscordUser added in v3.6.5

type DiscordUser struct {
	Username string `json:"global_name"`
	Avatar   string `json:"avatar"`
	ID       string `json:"id"`
}

func (DiscordUser) GetID added in v3.6.5

func (du DiscordUser) GetID() string

type GitHubUser added in v3.6.5

type GitHubUser struct {
	Login string `json:"login"`
	ID    uint64 `json:"id"`
}

func (GitHubUser) GetID added in v3.6.5

func (gu GitHubUser) GetID() uint64

type OAuthClaim added in v3.7.0

type OAuthClaim struct {
	Token *oauth2.Token `json:"token"`
	User  User          `json:"user"`
}

func (OAuthClaim) GetSubject added in v3.7.0

func (oac OAuthClaim) GetSubject() string

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)

func (User) GetSubject added in v3.8.0

func (u User) GetSubject() string

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