controller

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized = fmt.Errorf("unauthorized")
)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	DB  *gorm.DB
	JWT *jwt.JWT
}

func New

func New(options ...Option) (c *Controller, err error)

func (*Controller) Authorize added in v0.0.23

func (c *Controller) Authorize(jwtS string) (user models.User, err error)

func (*Controller) CreateLog added in v0.0.26

func (c *Controller) CreateLog(log *models.Log) (err error)

func (*Controller) GetLogs added in v0.0.26

func (c *Controller) GetLogs() (logs []models.Log, err error)

func (*Controller) GetLogsByDate added in v0.0.26

func (c *Controller) GetLogsByDate(filter *Filter[time.Time]) (logs []models.Log, err error)

func (*Controller) GetLogsByUser added in v0.0.26

func (c *Controller) GetLogsByUser(filter *Filter[models.User]) (logs []models.Log, err error)

func (*Controller) Login

func (c *Controller) Login(creds *models.User) (user models.User, err error)

func (*Controller) Register added in v0.0.21

func (c *Controller) Register(user *models.User) (err error)

func (*Controller) UpdatePassword added in v0.0.23

func (c *Controller) UpdatePassword(session *models.User, req *UpdatePasswordRequest) (err error)

func (*Controller) UserByUsername added in v0.0.23

func (c *Controller) UserByUsername(req *UserRequest) (user models.User, err error)

func (*Controller) UsernameByUUID added in v0.0.31

func (c *Controller) UsernameByUUID(req *UserRequest) (user models.User, err error)

type Filter added in v0.0.26

type Filter[T any] struct {
	Object       T   `json:"object"`
	ItemsPerPage int `json:"itemsPerPage"`
	Page         int `json:"page"`
}

type Option

type Option func(c *Controller) error

func WithDB

func WithDB(db *gorm.DB) Option

func WithSecret

func WithSecret[T string | []byte](secret T) Option

type UpdatePasswordRequest added in v0.0.23

type UpdatePasswordRequest struct {
	OldPassword string `json:"oldPassword"`
	NewPassword string `json:"newPassword"`
}

type UserRequest added in v0.0.23

type UserRequest struct {
	Username string `json:"username,omitempty"`
	UUID     string `json:"uuid,omitempty"`
}

Jump to

Keyboard shortcuts

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