persistence

package
v0.0.0-...-884cfb1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB

DB is the database object shared by everyone

View Source
var ErrWrongCredentials = errors.New("Wrong credentials")

ErrWrongCredentials is returned when username or password does not match

Functions

func GetValidatedChallengePerUser

func GetValidatedChallengePerUser() (map[string][]*TerminatedJob, error)

GetValidatedChallengePerUser returns a map containing for each user its validated challenges

func InitDatabase

func InitDatabase() error

InitDatabase return a singleton database object

Types

type TerminatedJob

type TerminatedJob struct {
	UUID      string
	Challenge string
	Username  string
	Code      string
	Status    int
	Created   time.Time
}

TerminatedJob is a struct which allow to save job that ended in base

func GetLastNJobs

func GetLastNJobs(count int) ([]*TerminatedJob, error)

GetLastNJobs gets a given amount of jobs from the database

func NewTerminatedJobFromJob

func NewTerminatedJobFromJob(slug string, user *User, job *tasks.Job) (*TerminatedJob, error)

NewTerminatedJobFromJob returns a terminated and persisted job

type User

type User struct {
	Username string

	Created time.Time
	// contains filtered or unexported fields
}

User struct containing user informations

func GetUser

func GetUser(username string) (*User, error)

GetUser from database without checking its password

func LoginUser

func LoginUser(username string, password string) (*User, error)

LoginUser search a user in the database and return this user if the user exists

func NewUser

func NewUser(username string, password string) (*User, error)

NewUser creates and adds a new user to the database

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword hash users password

Jump to

Keyboard shortcuts

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