user

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

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

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 Config added in v0.6.35

type Config struct {
	InactiveEmailTag string
}

type Filter

type Filter struct {
	Limit                     int32
	Page                      int32
	Keyword                   string
	ProjectID                 string
	ServiceDataKeyResourceIds []string
}

type LogData added in v0.6.25

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

type MetadataKeyLogData added in v0.6.25

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

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)
	DeleteByEmail(ctx context.Context, email string, emailTag string) error
	DeleteByID(ctx context.Context, id string, emailTag string) error
}

type Service

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

func NewService

func NewService(logger log.Logger, config Config, 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) Delete added in v0.6.35

func (s Service) Delete(ctx context.Context, id string) 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) ToLogData added in v0.6.25

func (user User) ToLogData() LogData

type UserMetadataKey

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

func (UserMetadataKey) ToMetadataKeyLogData added in v0.6.25

func (userMetadataKey UserMetadataKey) ToMetadataKeyLogData() MetadataKeyLogData

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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