model

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotExist is returned when a user does not exist
	ErrNotExist = errors.New("user does not exist")
)

Functions

This section is empty.

Types

type Credentials added in v0.8.0

type Credentials struct {
	Login    string `json:"login"`    // Username or Email
	Password string `json:"password"` // Password
}

Credentials holds credential data

type Device

type Device struct {
	ID      int    `json:"id" storm:"id,increment"` // device id
	Name    string `json:"name" storm:"unique"`     // device slug
	Host    string `json:"host" storm:"unique"`     // device url
	Title   string `json:"title"`
	Sockets []struct {
		Type        string `json:"type"`        // type string representation, i.e. for providing proper icons
		Description string `json:"description"` // human readable socket description
	} `json:"sockets"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Device holds device data

func NewDevice

func NewDevice(name, host, title string) (*Device, error)

NewDevice ...

type Message

type Message struct {
	Error string `json:"error"`
}

Message ...

type User

type User struct {
	ID       int    `json:"id" storm:"id,increment"` // user id
	Username string `json:"username" storm:"unique"` // user name
	Password string `json:"-"`                       // encrypted password
	Email    string `json:"email" storm:"unique"`
	Name     string `json:"name"`
	Admin    bool   `json:"admin"`
	Role     string `json:"role"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

User holds a user data

func NewUser added in v0.6.0

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

NewUser initializes a new user from a username, email and password

func (*User) Authenticate added in v0.6.0

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

Authenticate a user from a password

func (*User) SetRole added in v0.6.0

func (u *User) SetRole(db *store.DB, roleName string) error

SetRole sets the users Role with roleName

Jump to

Keyboard shortcuts

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