user

package
v0.0.0-...-c4f7e29 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnonymizedUser = apierrors.Forbidden.WithReason("AnonymizedUser")
View Source
var DeactivatedUser = apierrors.Forbidden.WithReason("DeactivatedUser")
View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(Store), "*"),
	wire.Bind(new(store), new(*Store)),
	wire.Struct(new(Commands), "*"),
	wire.Struct(new(Queries), "*"),
	wire.Struct(new(RawQueries), "*"),
	wire.Struct(new(RawCommands), "*"),
	wire.Struct(new(Provider), "*"),
)
View Source
var DisabledUser = apierrors.Forbidden.WithReason("DisabledUser")
View Source
var ErrAnonymizedUser = AnonymizedUser.New("user is anonymized")
View Source
var ErrDeactivatedUser = DeactivatedUser.New("user is deactivated")
View Source
var ErrUserNotFound = errors.New("user not found")
View Source
var InvalidAccountStatusTransition = apierrors.Invalid.WithReason("InvalidAccountStatusTransition")
View Source
var ScheduledAnonymizationByAdmin = apierrors.Forbidden.WithReason("ScheduledAnonymizationByAdmin")
View Source
var ScheduledDeletionByAdmin = apierrors.Forbidden.WithReason("ScheduledDeletionByAdmin")
View Source
var ScheduledDeletionByEndUser = apierrors.Forbidden.WithReason("ScheduledDeletionByEndUser")

Functions

func IsAccountStatusError

func IsAccountStatusError(err error) bool

func NewErrDisabledUser

func NewErrDisabledUser(reason *string) error

func NewErrScheduledAnonymizationByAdmin

func NewErrScheduledAnonymizationByAdmin(anonymizeAt time.Time) error

func NewErrScheduledDeletionByAdmin

func NewErrScheduledDeletionByAdmin(deleteAt time.Time) error

func NewErrScheduledDeletionByEndUser

func NewErrScheduledDeletionByEndUser(deleteAt time.Time) error

Types

type AccountStatus

type AccountStatus struct {
	IsDisabled    bool
	IsDeactivated bool
	DisableReason *string
	DeleteAt      *time.Time
	IsAnonymized  bool
	AnonymizeAt   *time.Time
}

AccountStatus represents disabled, deactivated, or scheduled deletion state. The zero value means normal.

func (AccountStatus) Anonymize

func (s AccountStatus) Anonymize() (*AccountStatus, error)

func (AccountStatus) Check

func (s AccountStatus) Check() error

func (AccountStatus) Disable

func (s AccountStatus) Disable(reason *string) (*AccountStatus, error)

func (AccountStatus) Reenable

func (s AccountStatus) Reenable() (*AccountStatus, error)

func (AccountStatus) ScheduleAnonymizationByAdmin

func (s AccountStatus) ScheduleAnonymizationByAdmin(anonymizeAt time.Time) (*AccountStatus, error)

func (AccountStatus) ScheduleDeletionByAdmin

func (s AccountStatus) ScheduleDeletionByAdmin(deleteAt time.Time) (*AccountStatus, error)

func (AccountStatus) ScheduleDeletionByEndUser

func (s AccountStatus) ScheduleDeletionByEndUser(deleteAt time.Time) (*AccountStatus, error)

func (AccountStatus) Type

func (AccountStatus) UnscheduleAnonymizationByAdmin

func (s AccountStatus) UnscheduleAnonymizationByAdmin() (*AccountStatus, error)

func (AccountStatus) UnscheduleDeletionByAdmin

func (s AccountStatus) UnscheduleDeletionByAdmin() (*AccountStatus, error)

type AccountStatusType

type AccountStatusType string
const (
	AccountStatusTypeNormal                         AccountStatusType = "normal"
	AccountStatusTypeDisabled                       AccountStatusType = "disabled"
	AccountStatusTypeDeactivated                    AccountStatusType = "deactivated"
	AccountStatusTypeScheduledDeletionDisabled      AccountStatusType = "scheduled_deletion_disabled"
	AccountStatusTypeScheduledDeletionDeactivated   AccountStatusType = "scheduled_deletion_deactivated"
	AccountStatusTypeAnonymized                     AccountStatusType = "anonymized"
	AccountStatusTypeScheduledAnonymizationDisabled AccountStatusType = "scheduled_anonymization_disabled"
)

type AuthenticatorService

type AuthenticatorService interface {
	ListByUserIDs(userIDs []string, filters ...authenticator.Filter) (map[string][]*authenticator.Info, error)
}

type Commands

type Commands struct {
	*RawCommands
	RawQueries         *RawQueries
	Events             EventService
	Verification       VerificationService
	UserProfileConfig  *config.UserProfileConfig
	StandardAttributes StandardAttributesService
	CustomAttributes   CustomAttributesService
	Web3               Web3Service
	RolesAndGroups     RolesAndGroupsService
}

func (*Commands) AfterCreate

func (c *Commands) AfterCreate(
	user *User,
	identities []*identity.Info,
	authenticators []*authenticator.Info,
	isAdminAPI bool,
) error

type CustomAttributesService

type CustomAttributesService interface {
	ReadCustomAttributesInStorageForm(role accesscontrol.Role, userID string, storageForm map[string]interface{}) (map[string]interface{}, error)
	ReadCustomAttributesInStorageFormForUsers(
		role accesscontrol.Role,
		userIDs []string,
		storageForms []map[string]interface{},
	) (map[string]map[string]interface{}, error)
}

type EventService

type EventService interface {
	DispatchEventOnCommit(payload event.Payload) error
}

type FilterOptions

type FilterOptions struct {
	GroupKeys []string
	RoleKeys  []string
}

func (FilterOptions) IsFilterEnabled

func (o FilterOptions) IsFilterEnabled() bool

type IdentityService

type IdentityService interface {
	ListByUserIDs(userIDs []string) (map[string][]*identity.Info, error)
}

type ListOptions

type ListOptions struct {
	SortOption SortOption
}

type Provider

type Provider struct {
	*Commands
	*Queries
}

type Queries

type Queries struct {
	*RawQueries
	Store              store
	Identities         IdentityService
	Authenticators     AuthenticatorService
	Verification       VerificationService
	StandardAttributes StandardAttributesService
	CustomAttributes   CustomAttributesService
	Web3               Web3Service
	RolesAndGroups     RolesAndGroupsService
}

func (*Queries) Get

func (p *Queries) Get(id string, role accesscontrol.Role) (*model.User, error)

func (*Queries) GetMany

func (p *Queries) GetMany(ids []string, role accesscontrol.Role) (users []*model.User, err error)

type RawCommands

type RawCommands struct {
	Store store
	Clock clock.Clock
}

func (*RawCommands) AfterCreate

func (c *RawCommands) AfterCreate(userModel *model.User, identities []*identity.Info) error

func (*RawCommands) Anonymize

func (c *RawCommands) Anonymize(userID string) error

func (*RawCommands) Create

func (c *RawCommands) Create(userID string) (*User, error)

func (*RawCommands) Delete

func (c *RawCommands) Delete(userID string) error

func (*RawCommands) New

func (c *RawCommands) New(userID string) *User

func (*RawCommands) UpdateAccountStatus

func (c *RawCommands) UpdateAccountStatus(userID string, accountStatus AccountStatus) error

func (*RawCommands) UpdateLoginTime

func (c *RawCommands) UpdateLoginTime(userID string, loginAt time.Time) error

type RawQueries

type RawQueries struct {
	Store store
}

func (*RawQueries) Count

func (p *RawQueries) Count() (uint64, error)

func (*RawQueries) GetManyRaw

func (p *RawQueries) GetManyRaw(ids []string) ([]*User, error)

func (*RawQueries) GetRaw

func (p *RawQueries) GetRaw(id string) (*User, error)

func (*RawQueries) QueryPage

func (p *RawQueries) QueryPage(listOption ListOptions, pageArgs graphqlutil.PageArgs) ([]model.PageItemRef, error)

type RolesAndGroupsService

type RolesAndGroupsService interface {
	ListRolesByUserID(userID string) ([]*model.Role, error)
	ListGroupsByUserID(userID string) ([]*model.Group, error)
	ListRolesByUserIDs(userIDs []string) (map[string][]*model.Role, error)
	ListGroupsByUserIDs(userIDs []string) (map[string][]*model.Group, error)
}

type SortBy

type SortBy string
const (
	SortByDefault     SortBy = ""
	SortByCreatedAt   SortBy = "created_at"
	SortByLastLoginAt SortBy = "last_login_at"
)

type SortOption

type SortOption struct {
	SortBy        SortBy
	SortDirection model.SortDirection
}

func (SortOption) Apply

func (o SortOption) Apply(builder db.SelectBuilder) db.SelectBuilder

type StandardAttributesService

type StandardAttributesService interface {
	DeriveStandardAttributes(role accesscontrol.Role, userID string, updatedAt time.Time, attrs map[string]interface{}) (map[string]interface{}, error)
	DeriveStandardAttributesForUsers(
		role accesscontrol.Role,
		userIDs []string,
		updatedAts []time.Time,
		attrsList []map[string]interface{},
	) (map[string]map[string]interface{}, error)
}

type Store

type Store struct {
	SQLBuilder  *appdb.SQLBuilderApp
	SQLExecutor *appdb.SQLExecutor
	Clock       clock.Clock
	AppID       config.AppID
}

func (*Store) Anonymize

func (s *Store) Anonymize(userID string) error

func (*Store) Count

func (s *Store) Count() (uint64, error)

func (*Store) Create

func (s *Store) Create(u *User) (err error)

func (*Store) Delete

func (s *Store) Delete(userID string) error

func (*Store) Get

func (s *Store) Get(userID string) (*User, error)

func (*Store) GetByIDs

func (s *Store) GetByIDs(userIDs []string) ([]*User, error)

func (*Store) MarkAsReindexRequired

func (s *Store) MarkAsReindexRequired(userIDs []string) error

func (*Store) QueryPage

func (s *Store) QueryPage(listOption ListOptions, pageArgs graphqlutil.PageArgs) ([]*User, uint64, error)

func (*Store) UpdateAccountStatus

func (s *Store) UpdateAccountStatus(userID string, accountStatus AccountStatus) error

func (*Store) UpdateCustomAttributes

func (s *Store) UpdateCustomAttributes(userID string, customAttrs map[string]interface{}) error

func (*Store) UpdateLastIndexedAt

func (s *Store) UpdateLastIndexedAt(userIDs []string, at time.Time) error

func (*Store) UpdateLoginTime

func (s *Store) UpdateLoginTime(userID string, loginAt time.Time) error

func (*Store) UpdateStandardAttributes

func (s *Store) UpdateStandardAttributes(userID string, stdAttrs map[string]interface{}) error

type User

type User struct {
	ID                  string
	CreatedAt           time.Time
	UpdatedAt           time.Time
	MostRecentLoginAt   *time.Time
	LessRecentLoginAt   *time.Time
	IsDisabled          bool
	DisableReason       *string
	IsDeactivated       bool
	DeleteAt            *time.Time
	IsAnonymized        bool
	AnonymizeAt         *time.Time
	StandardAttributes  map[string]interface{}
	CustomAttributes    map[string]interface{}
	LastIndexedAt       *time.Time
	RequireReindexAfter *time.Time
}

func (*User) AccountStatus

func (u *User) AccountStatus() AccountStatus

func (*User) GetMeta

func (u *User) GetMeta() model.Meta

func (*User) ToRef

func (u *User) ToRef() *model.UserRef

type VerificationService

type VerificationService interface {
	IsUserVerified(identities []*identity.Info) (bool, error)
	AreUsersVerified(identitiesByUserIDs map[string][]*identity.Info) (map[string]bool, error)
}

type Web3Service

type Web3Service interface {
	GetWeb3Info(identities []*identity.Info) (*model.UserWeb3Info, error)
}

Jump to

Keyboard shortcuts

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