db

package
v0.0.0-...-22e6143 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	NewUser(u User) error
	GetSolvesWithTime(u string) []_ORMChallengesByUser
	Get(username string) (User, error)
	Contains(username, displayname string) bool
	Login(username, password string) error
	GetUserCount() int64
	GetSolveCount(chall types.Challenge) int64
	UpdateUser(u User) error
	DeleteUser(u User) error
	SolvedChallenge(u User, c *types.Challenge) error
	UserExists(u User) (bool, error)
	DisplayNameExists(n string) (bool, error)
	ChallengesSolved(u User) ([]*types.Challenge, error)
	LoadUser(username string) (User, error)
	UserByToken(token string) (User, error)
	AllUsersSortedByPoints() ([]User, error)
}

func StartDB

func StartDB(c *types.Challenges) (DB, error)

StartDB starts the db and returns a DB interface

type User

type User struct {
	Name         string `json:"name"`
	Hash         []byte
	DisplayName  string `json:"displayname"`
	Completed    []*types.Challenge
	Admin        bool `json:"admin"`
	Points       int  `json:"points"`
	VerifiedInfo VerifyInfo
	Created      time.Time
}

User was ist das wohl

func NewUserStruct

func NewUserStruct(d DB, name, password, displayname string) (User, error)

NewUserStruct creates a new user object

func (*User) CalculatePoints

func (u *User) CalculatePoints()

CalculatePoints calculates Points and updates user.Points

func (*User) ComparePassword

func (u *User) ComparePassword(password string) bool

ComparePassword checks if the password is valid

func (User) HasSolvedChallenge

func (u User) HasSolvedChallenge(chall *types.Challenge) bool

HasSolvedChallenge returns true if u has solved chall

type VerifyInfo

type VerifyInfo struct {
	IsVerified     bool
	VerifyToken    string
	VerifyDeadline time.Time
}

VerifyInfo saves if a users e-mail is verified

Jump to

Keyboard shortcuts

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