user

package
v0.6.19 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuditKeyUserCreate = "user.create"
	AuditKeyUserUpdate = "user.update"
)

Variables

View Source
var (
	ErrNotExist         = errors.New("user doesn't exist")
	ErrInvalidID        = errors.New("user id is invalid")
	ErrInvalidEmail     = errors.New("user email is invalid")
	ErrConflict         = errors.New("user already exist")
	ErrEmptyKey         = errors.New("empty key")
	ErrKeyAlreadyExists = errors.New("key already exist")
	ErrKeyDoesNotExists = errors.New("key does not exist")
	ErrMissingEmail     = errors.New("user email is missing")
	ErrInvalidUUID      = errors.New("invalid syntax of uuid")
	ErrLogActivity      = errors.New("error while logging activity")
)

Functions

func GetEmailFromContext

func GetEmailFromContext(ctx context.Context) (string, bool)

func SetContextWithEmail

func SetContextWithEmail(ctx context.Context, email string) context.Context

Types

type ActivityService added in v0.6.15

type ActivityService interface {
	Log(ctx context.Context, action string, actor activity.Actor, data any) error
}

type Filter

type Filter struct {
	Limit   int32
	Page    int32
	Keyword string
}

type PagedUsers

type PagedUsers struct {
	Count int32
	Users []User
}

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (User, error)
	GetByEmail(ctx context.Context, email string) (User, error)
	GetByIDs(ctx context.Context, userIds []string) ([]User, error)
	Create(ctx context.Context, user User) (User, error)
	List(ctx context.Context, flt Filter) ([]User, error)
	UpdateByID(ctx context.Context, toUpdate User) (User, error)
	UpdateByEmail(ctx context.Context, toUpdate User) (User, error)
	CreateMetadataKey(ctx context.Context, key UserMetadataKey) (UserMetadataKey, error)
}

type Service

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

func NewService

func NewService(logger log.Logger, repository Repository, activityService ActivityService) *Service

func (Service) Create

func (s Service) Create(ctx context.Context, user User) (User, error)

func (Service) CreateMetadataKey

func (s Service) CreateMetadataKey(ctx context.Context, key UserMetadataKey) (UserMetadataKey, error)

func (Service) FetchCurrentUser

func (s Service) FetchCurrentUser(ctx context.Context) (User, error)

func (Service) Get added in v0.6.8

func (s Service) Get(ctx context.Context, idOrEmail string) (User, error)

func (Service) GetByEmail

func (s Service) GetByEmail(ctx context.Context, email string) (User, error)

func (Service) GetByID

func (s Service) GetByID(ctx context.Context, id string) (User, error)

func (Service) GetByIDs

func (s Service) GetByIDs(ctx context.Context, userIDs []string) ([]User, error)

func (Service) List

func (s Service) List(ctx context.Context, flt Filter) (PagedUsers, error)

func (Service) UpdateByEmail

func (s Service) UpdateByEmail(ctx context.Context, toUpdate User) (User, error)

func (Service) UpdateByID

func (s Service) UpdateByID(ctx context.Context, toUpdate User) (User, error)

type User

type User struct {
	ID        string
	Name      string
	Email     string
	Metadata  metadata.Metadata
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (User) ToUserLogData added in v0.6.15

func (user User) ToUserLogData() UserLogData

type UserLogData added in v0.6.15

type UserLogData struct {
	Entity string `mapstructure:"entity"`
	Name   string `mapstructure:"name"`
	Email  string `mapstructure:"email"`
}

type UserMetadataKey

type UserMetadataKey struct {
	Key         string
	Description string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

func (UserMetadataKey) ToUserMetadataKeyLogData added in v0.6.15

func (userMetadataKey UserMetadataKey) ToUserMetadataKeyLogData() UserMetadataKeyLogData

type UserMetadataKeyLogData added in v0.6.15

type UserMetadataKeyLogData struct {
	Entity      string `mapstructure:"entity"`
	Key         string `mapstructure:"key"`
	Description string `mapstructure:"description"`
}

Jump to

Keyboard shortcuts

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