state

package
v0.0.0-...-17e3bd2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONFIG_FILE   = "config.yaml"
	USERS_DB_FILE = "users.db"
)

Constants

Variables

View Source
var (
	Users *UserList
	Conf  *Config
)
View Source
var (
	ErrInvalidUser       = errors.New("user does not exist")
	ErrUserExists        = errors.New("user exists")
	ErrIncorrectPassword = errors.New("incorrect password")
	ErrUserDisabled      = errors.New("user account is disabled")
)

Error definitions

Functions

func Init

func Init(wikiDir string) error

Types

type Config

type Config struct {
	Wiki   ConfigWiki `yaml:"wiki"`
	Files  configFiles
	Server configServer `yaml:"server"`
}

Configuration structs

func (*Config) ParseConfig

func (cfg *Config) ParseConfig(configFile string) error

type ConfigWiki

type ConfigWiki struct {
	SiteTitle       string `yaml:"title"`
	SiteDescription string `yaml:"description"`
	Theme           string `yaml:"theme"`
	IndexPage       string `yaml:"index"`
	DocumentRoot    string `yaml:"document_root"`
}

type User

type User struct {
	Enabled  bool   // Account enabled
	Username string // Username

	FullName string // Full Name
	Email    string // Email address
	Id       int    // User ID
	// contains filtered or unexported fields
}

type UserList

type UserList struct {
	Users map[string]User
}

func (*UserList) Authenticate

func (ul *UserList) Authenticate(username string, password string) (*User, error)

Authenticate using username and password

func (*UserList) Commit

func (ul *UserList) Commit() error

Write any changes to disk

func (*UserList) GetUser

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

Get information about the user, returns nil if user does not exist

func (*UserList) ReadDatabase

func (ul *UserList) ReadDatabase(dbFile string) error

ReadAuthDatabase - reads the database file

func (*UserList) Register

func (ul *UserList) Register(username string, password string, fullName string, email string) error

Create a new account

Jump to

Keyboard shortcuts

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