users

package
v2.14.2-0...-e73e639 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPwd

func CheckPwd(password, hash string) bool

CheckPwd checks if a password is correct.

func HashPwd

func HashPwd(password string) (string, error)

HashPwd hashes a password.

Types

type Permissions

type Permissions struct {
	Admin    bool `json:"admin"`
	Execute  bool `json:"execute"`
	Create   bool `json:"create"`
	Rename   bool `json:"rename"`
	Modify   bool `json:"modify"`
	Delete   bool `json:"delete"`
	Share    bool `json:"share"`
	Download bool `json:"download"`
}

Permissions describe a user's permissions.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage is a users storage.

func NewStorage

func NewStorage(back StorageBackend) *Storage

NewStorage creates a users storage from a backend.

func (*Storage) Delete

func (s *Storage) Delete(id interface{}) error

Delete allows you to delete a user by its name or username. The provided id must be a string for username lookup or a uint for id lookup. If id is neither, a ErrInvalidDataType will be returned.

func (*Storage) Get

func (s *Storage) Get(baseScope string, id interface{}) (user *User, err error)

Get allows you to get a user by its name or username. The provided id must be a string for username lookup or a uint for id lookup. If id is neither, a ErrInvalidDataType will be returned.

func (*Storage) Gets

func (s *Storage) Gets(baseScope string) ([]*User, error)

Gets gets a list of all users.

func (*Storage) LastUpdate

func (s *Storage) LastUpdate(id uint) int64

LastUpdate gets the timestamp for the last update of an user.

func (*Storage) Save

func (s *Storage) Save(user *User) error

Save saves the user in a storage.

func (*Storage) Update

func (s *Storage) Update(user *User, fields ...string) error

Update updates a user in the database.

type StorageBackend

type StorageBackend interface {
	GetBy(interface{}) (*User, error)
	Gets() ([]*User, error)
	Save(u *User) error
	Update(u *User, fields ...string) error
	DeleteByID(uint) error
	DeleteByUsername(string) error
}

StorageBackend is the interface to implement for a users storage.

type Store

type Store interface {
	Get(baseScope string, id interface{}) (user *User, err error)
	Gets(baseScope string) ([]*User, error)
	Update(user *User, fields ...string) error
	Save(user *User) error
	Delete(id interface{}) error
	LastUpdate(id uint) int64
}

type User

type User struct {
	ID           uint          `storm:"id,increment" json:"id"`
	Username     string        `storm:"unique" json:"username"`
	Password     string        `json:"password"`
	Scope        string        `json:"scope"`
	Locale       string        `json:"locale"`
	LockPassword bool          `json:"lockPassword"`
	ViewMode     ViewMode      `json:"viewMode"`
	SingleClick  bool          `json:"singleClick"`
	Perm         Permissions   `json:"perm"`
	Commands     []string      `json:"commands"`
	Sorting      files.Sorting `json:"sorting"`
	Fs           afero.Fs      `json:"-" yaml:"-"`
	Rules        []rules.Rule  `json:"rules"`
	HideDotfiles bool          `json:"hideDotfiles"`
}

User describes a user.

func (*User) CanExecute

func (u *User) CanExecute(command string) bool

CanExecute checks if an user can execute a specific command.

func (*User) Clean

func (u *User) Clean(baseScope string, fields ...string) error

Clean cleans up a user and verifies if all its fields are alright to be saved.

func (*User) FullPath

func (u *User) FullPath(path string) string

FullPath gets the full path for a user's relative path.

func (*User) GetRules

func (u *User) GetRules() []rules.Rule

GetRules implements rules.Provider.

type ViewMode

type ViewMode string

ViewMode describes a view mode.

const (
	ListViewMode   ViewMode = "list"
	MosaicViewMode ViewMode = "mosaic"
)

Jump to

Keyboard shortcuts

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