model

package
v0.0.0-...-0e98184 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DeviceTypeCommunal = "communal"
View Source
const DeviceTypeCompanion = "companion"

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Token    string `json:"token"`
}

type Client

type Client struct {
	ID           bson.ObjectId `bson:"_id,omitempty" jsonapi:"primary,clients"`
	ClientID     string        `bson:"client_id" jsonapi:"attr,client_id"`
	ClientSecret string        `bson:"client_secret" jsonapi:"attr,client_secret"`
}

type Device

type Device struct {
	ID    string        `bson:"_id" json:"id"`
	Type  string        `bson:"type" json:"type"`
	Code  string        `bson:"code" json:"code,omitempty"`
	Owner bson.ObjectId `bson:"owner,omitempty" json:"owner,omitempty"`
	Aux   string        `bson:"aux,omitempty" json:"aux,omitempty"`
}

func (*Device) GenerateId

func (d *Device) GenerateId()

func (*Device) RefreshCode

func (d *Device) RefreshCode()

RefreshCode generates a new random 6 digit connection code

type Entity

type Entity interface {
	GetType() string
}

type Key

type Key struct {
	ID    bson.ObjectId `bson:"_id,omitempty" json:"id"`
	Title string        `bson:"title" json:"title,omitempty"`
	Slug  string        `bson:"slug" json:"slug,omitempty"`
	Data  []byte        `bson:"data,omitempty" json:"data"`
}

func (*Key) GenerateSlug

func (k *Key) GenerateSlug()

type Profile

type Profile struct {
	Companion map[string]interface{} `bson:"companion" json:"companion"`
	Communal  map[string]interface{} `bson:"communal"  json:"communal"`
}

The Profile type provides a map for companion and communal devices allowing arbitry storage of key value pairs.

type Token

type Token struct {
	ID        bson.ObjectId `bson:"_id,omitempty" json:"-"`
	ExpiresAt time.Time     `bson:"expires" json:"expires_at"`
	Token     string        `bson:"token" json:"access_token"`
	User      bson.ObjectId `bson:"user" json:"-"`
	Client    bson.ObjectId `bson:"client,omitempty" json:"-"`
	Aux       string        `bson:"aux,omitempty" json:"aux,omitempty"`
}

func NewToken

func NewToken(user User) Token

type User

type User struct {
	ID            bson.ObjectId          `bson:"_id,omitempty" json:"id"`
	DisplayName   string                 `bson:"display_name,omitempty" json:"display_name,omitempty"`
	FirstName     string                 `bson:"first_name,omitempty" json:"first_name,omitempty"`
	LastName      string                 `bson:"last_name,omitempty" json:"last_name,omitempty"`
	Email         string                 `bson:"email,omitempty" json:"email"`
	PlainPassword string                 `bson:"-" json:"password,omitempty"`
	Password      []byte                 `bson:"password,omitempty" json:"-"`
	Roles         []string               `bson:"roles,omitempty" json:"roles,omitempty"`
	Groups        []string               `bson:"groups,omitempty" json:"groups,omitempty"`
	Settings      map[string]interface{} `bson:"settings" json:"settings"`
	Profile       *Profile               `bson:"profile,omitempty" json:"profile,omitempty"`
}

The User type encapsulates details about a user and their profile

func (*User) HasRole

func (u *User) HasRole(role string) bool

func (*User) HashPassword

func (u *User) HashPassword() error

func (*User) ValidatePassword

func (u *User) ValidatePassword(pass string) bool

Jump to

Keyboard shortcuts

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