users

package
v0.0.0-...-80f9fc5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePwd

func ComparePwd(hash, pwd string) error

func NewUserContext

func NewUserContext(ctx context.Context, user *User) context.Context

Types

type Permissions

type Permissions struct {
	Admin     bool      `json:"admin"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Storage

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

func NewStorage

func NewStorage(provider StorageProvider) *Storage

func (*Storage) Delete

func (s *Storage) Delete(id uint) error

func (*Storage) GetBy

func (s *Storage) GetBy(v interface{}) (*User, error)

func (*Storage) List

func (s *Storage) List(limit, after int) ([]User, error)

func (*Storage) Save

func (s *Storage) Save(u *User) (err error)

func (*Storage) Update

func (s *Storage) Update(u *User) (err error)

type StorageProvider

type StorageProvider interface {
	Page(limit, after int) ([]User, error)
	GetByID(uint) (*User, error)
	GetByUsername(string) (*User, error)
	Save(u *User) error
	Update(u *User) error
	Delete(id uint) error
}

type User

type User struct {
	ID        uint        `json:"id"`
	Name      string      `json:"name"`
	Username  string      `json:"username"`
	Password  string      `json:"password"`
	Perm      Permissions `json:"perm"`
	CreatedAt time.Time   `json:"created_at"`
}

func UserFromContext

func UserFromContext(ctx context.Context) *User

Jump to

Keyboard shortcuts

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