filemanager: github.com/hacdias/filemanager/users Index | Files

package users

import "github.com/hacdias/filemanager/users"

Index

Package Files

password.go permissions.go storage.go users.go

func CheckPwd Uses

func CheckPwd(password, hash string) bool

CheckPwd checks if a password is correct.

func HashPwd Uses

func HashPwd(password string) (string, error)

HashPwd hashes a password.

type Permissions Uses

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 Uses

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

Storage is a users storage.

func NewStorage Uses

func NewStorage(back StorageBackend) *Storage

NewStorage creates a users storage from a backend.

func (*Storage) Delete Uses

func (s *Storage) Delete(id interface{}) (err 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 Uses

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 Uses

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

Gets gets a list of all users.

func (*Storage) LastUpdate Uses

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

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

func (*Storage) Save Uses

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

Save saves the user in a storage.

func (*Storage) Update Uses

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

Update updates a user in the database.

type StorageBackend Uses

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 Uses

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 Uses

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

CanExecute checks if an user can execute a specific command.

func (*User) Clean Uses

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 Uses

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

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

func (*User) GetRules Uses

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

GetRules implements rules.Provider.

type ViewMode Uses

type ViewMode string

ViewMode describes a view mode.

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

Package users imports 9 packages (graph). Updated 2019-07-01. Refresh now. Tools for package owners.