users

package
v0.90.74 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Samples

func Samples() error

func SetDB

func SetDB(database database.Database)

Types

type Scope added in v0.90.57

type Scope string
const (
	FullAdmin   Scope = "admin"
	ReadOnly    Scope = "readonly"
	RServices   Scope = "read:services"
	RWServices  Scope = "write:services"
	RIncidents  Scope = "read:incidents"
	RWIncidents Scope = "write:incidents"

	EmptyUser Scope = "none"
)

type User

type User struct {
	Id        int64         `gorm:"primary_key;column:id" json:"id"`
	Username  string        `gorm:"type:varchar(100);unique;column:username;" json:"username,omitempty"`
	Password  string        `gorm:"column:password" json:"password,omitempty"`
	Email     string        `gorm:"type:varchar(100);column:email" json:"email,omitempty"`
	ApiKey    string        `gorm:"column:api_key" json:"api_key,omitempty"`
	Scopes    string        `gorm:"column:scopes" json:"scopes,omitempty"`
	Admin     null.NullBool `gorm:"column:administrator" json:"admin,omitempty"`
	CreatedAt time.Time     `gorm:"column:created_at" json:"created_at"`
	UpdatedAt time.Time     `gorm:"column:updated_at" json:"updated_at"`
	Token     string        `gorm:"-" json:"token"`
}

User is the main struct for Users

func All

func All() []*User

func AuthUser

func AuthUser(username, passwordHash string) (*User, bool)

AuthUser will return the User and a boolean if authentication was correct. accepts username, and password as a string

func Find

func Find(id int64) (*User, error)

func FindByAPIKey added in v0.90.57

func FindByAPIKey(key string) (*User, error)

func FindByUsername

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

func (*User) AfterCreate added in v0.90.53

func (u *User) AfterCreate()

func (*User) AfterDelete added in v0.90.53

func (u *User) AfterDelete()

func (*User) AfterFind added in v0.90.53

func (u *User) AfterFind()

func (*User) AfterUpdate added in v0.90.53

func (u *User) AfterUpdate()

func (*User) AllScopes added in v0.90.57

func (u *User) AllScopes() []Scope

func (*User) BeforeCreate

func (u *User) BeforeCreate() error

func (*User) BeforeDelete added in v0.90.65

func (u *User) BeforeDelete() error

func (*User) BeforeUpdate added in v0.90.62

func (u *User) BeforeUpdate() error

func (*User) Create

func (u *User) Create() error

func (*User) Delete

func (u *User) Delete() error

func (*User) Update

func (u *User) Update() error

func (*User) Validate added in v0.90.62

func (u *User) Validate() error

Jump to

Keyboard shortcuts

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