Documentation
¶
Index ¶
- Constants
- Variables
- func GetEmailFromContext(ctx context.Context) (string, bool)
- func SetContextWithEmail(ctx context.Context, email string) context.Context
- type ActivityService
- type Config
- type Filter
- type LogData
- type MetadataKeyLogData
- type PagedUsers
- type Repository
- type Service
- func (s Service) Create(ctx context.Context, user User) (User, error)
- func (s Service) CreateMetadataKey(ctx context.Context, key UserMetadataKey) (UserMetadataKey, error)
- func (s Service) Delete(ctx context.Context, id string) error
- func (s Service) FetchCurrentUser(ctx context.Context) (User, error)
- func (s Service) Get(ctx context.Context, idOrEmail string) (User, error)
- func (s Service) GetByEmail(ctx context.Context, email string) (User, error)
- func (s Service) GetByID(ctx context.Context, id string) (User, error)
- func (s Service) GetByIDs(ctx context.Context, userIDs []string) ([]User, error)
- func (s Service) List(ctx context.Context, flt Filter) (PagedUsers, error)
- func (s Service) UpdateByEmail(ctx context.Context, toUpdate User) (User, error)
- func (s Service) UpdateByID(ctx context.Context, toUpdate User) (User, error)
- type User
- type UserMetadataKey
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 ¶
Types ¶
type ActivityService ¶ added in v0.6.15
type Filter ¶
type Filter struct {
Limit int32
Page int32
Keyword string
ProjectID string
ServiceDataKeyResourceIds []string
// MetadataPaths and the fields below filter users by their servicedata
// metadata, mirroring Guardian's appeal_details* generic JSONB filter. Each
// path is dot-delimited: the first segment is the metadata (servicedata) key
// and the remaining segments navigate into that key's JSON value, e.g.
// "functional_roles.roles". When empty, no metadata filter is applied.
MetadataPaths []string
// Positive filters (OR-ed together across paths). A matched value that is a
// JSON array matches when it contains the value.
Metadatas []string // equals / IN
MetadataStartsWith string
MetadataEndsWith string
MetadataContains string
// Negative filters (AND-ed together; user is excluded on a match).
NotMetadatas []string // not equals / NOT IN
MetadataNotStartsWith string
MetadataNotEndsWith string
MetadataNotContains string
}
type MetadataKeyLogData ¶ added in v0.6.25
type PagedUsers ¶
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) CreateMetadataKey ¶
func (s Service) CreateMetadataKey(ctx context.Context, key UserMetadataKey) (UserMetadataKey, error)
func (Service) FetchCurrentUser ¶
func (Service) GetByEmail ¶
func (Service) UpdateByEmail ¶
type User ¶
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
Click to show internal directories.
Click to hide internal directories.