Documentation ¶
Index ¶
- func CheckPwd(password, hash string) bool
- func HashPwd(password string) (string, error)
- type Permissions
- type Storage
- func (s *Storage) Delete(id interface{}) (err error)
- func (s *Storage) Get(baseScope string, id interface{}) (user *User, err error)
- func (s *Storage) Gets(baseScope string) ([]*User, error)
- func (s *Storage) LastUpdate(id uint) int64
- func (s *Storage) Save(user *User) error
- func (s *Storage) Update(user *User, fields ...string) error
- type StorageBackend
- type User
- type ViewMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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"` 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 ¶
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 ¶
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) LastUpdate ¶
LastUpdate gets the timestamp for the last update of an user.
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 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"` Perm Permissions `json:"perm"` Commands []string `json:"commands"` Sorting files.Sorting `json:"sorting"` Fs afero.Fs `json:"-" yaml:"-"` Rules []rules.Rule `json:"rules"` }
User describes a user.
func (*User) CanExecute ¶
CanExecute checks if an user can execute a specific command.