structs

package
v0.0.0-...-360a0c1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const LoginMaxAttempts = 3

Variables

View Source
var (
	ErrLoginInvalidKey = errors.New("invalid key")
	ErrLoginExpired    = errors.New("login expired")
	ErrInvalidInput    = errors.New("invalid input")
)
View Source
var TalkCategories = []string{
	"software-engineering",
	"distributed-systems",
	"programming-languages",
	"databases",
	"scientific-computing",
	"robotics",
	"artificial-intelligence",
	"automata-theory",
	"computer-networks",
	"computer-vision",
	"computer-architecture",
	"bioinformatics",
	"operating-systems",
	"data-structures",
	"computer-graphics",
	"medicine",
	"computer-security",
	"logic",
	"data-analytics",
	"machine-learning",
	"formal-methods",
	"master-thesis",
	"bachelor-thesis",
	"others",
}

Functions

This section is empty.

Types

type Capability

type Capability string
const (
	CapabilityAdmin        Capability = "admin"
	CapabilityImageUploads Capability = "img-uploads"
)

type Login

type Login struct {
	Expiration time.Time `json:"e"`
	User       string    `json:"u"`
	Key        string    `json:"k"`
	Code       string    `json:"c"`
	Attempt    int       `json:"a"`
}

func (*Login) Active

func (l *Login) Active() bool

type Session

type Session struct {
	Expiration time.Time `json:"e"`
	User       string    `json:"u"`
	Key        string    `json:"k"`
}

func (*Session) Active

func (s *Session) Active() bool

type Storage

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

Storage provides capabilities to access and manage both user and individual post data.

func NewStorage

func NewStorage(kv kv.Store, blob blob.Store, prefix string) *Storage

func (*Storage) AttemptLogin

func (storage *Storage) AttemptLogin(user string) (*Login, error)

func (*Storage) ConfirmLogin

func (storage *Storage) ConfirmLogin(key, code string) (*Session, *Login, error)

func (*Storage) DeleteSession

func (storage *Storage) DeleteSession(key string) error

func (*Storage) DeleteTalk

func (storage *Storage) DeleteTalk(ids ...int64) error

func (*Storage) HasActiveVerification

func (storage *Storage) HasActiveVerification(user string) (bool, error)

func (*Storage) HasTooManyLogins

func (storage *Storage) HasTooManyLogins(user string) (bool, int, error)

func (*Storage) InsertTalk

func (storage *Storage) InsertTalk(talk *Talk) error

func (*Storage) Talk

func (storage *Storage) Talk(id int64) (*Talk, error)

func (*Storage) Talks

func (storage *Storage) Talks() ([]*Talk, error)

func (*Storage) UpcomingTalks

func (storage *Storage) UpcomingTalks() ([]*Talk, error)

func (*Storage) UpdateTalk

func (storage *Storage) UpdateTalk(talk *Talk) error

func (*Storage) UploadImage

func (storage *Storage) UploadImage(objectName, imageBase64 string) (string, error)

func (*Storage) User

func (storage *Storage) User(id string) (User, error)

func (*Storage) Verify

func (storage *Storage) Verify(secret string) error

func (*Storage) VerifySession

func (storage *Storage) VerifySession(key string) (string, error)

type Talk

type Talk struct {
	ID         int64     `json:"i,omitempty"`
	Rank       int64     `json:"-"`
	User       string    `json:"u"`
	Title      string    `json:"t"`
	Category   string    `json:"c"`
	Date       time.Time `json:"d"`
	Link       string    `json:"l,omitempty"`
	LinkDomain string    `json:"-"`
	Body       string    `json:"b,omitempty"`
	Image      string    `json:"z,omitempty"`
	ImageURL   string    `json:"-"`
}

func (*Talk) RenderAsHTML

func (t *Talk) RenderAsHTML() string

type TooManyLoginsError

type TooManyLoginsError struct {
	Timeout int
}

func (TooManyLoginsError) Error

func (err TooManyLoginsError) Error() string

type User

type User struct {
	// The unique TUMonline identifier for this user.
	ID           string       `json:"i"`
	Capabilities []Capability `json:"c"`
}

func (*User) HasCapability

func (u *User) HasCapability(cap Capability) bool

Returns true if the user has the specified capability.

type Verification

type Verification struct {
	Expiration time.Time `json:"e"`
	Talk       *Talk     `json:"t"`
}

func (*Verification) Active

func (v *Verification) Active() bool

type WrongCodeError

type WrongCodeError struct {
	Attempt     int
	MaxAttempts int
}

func (WrongCodeError) Error

func (err WrongCodeError) Error() string

Jump to

Keyboard shortcuts

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