user

package
v0.0.0-...-61e3c9a Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInputIsEmpty     = errors.New("model: non-empty value must be provided")
	ErrUserUpdateFailed = errors.New("model: user update failed")
)
View Source
var (
	ErrUserNotFound      = errors.New("repository: the user was not found")
	ErrUserAlreadyExists = errors.New("repository: user already exists")
	ErrUserHasNoUpdates  = errors.New("repository: failed to update user")
)

Functions

This section is empty.

Types

type User

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

User is a aggregate that combines all entities needed to represent a user.

func NewUser

func NewUser(p core.Person, email, password string) (*User, error)

NewUser is a factory to create a new User aggregate.

func NewUserFromEvents

func NewUserFromEvents(events []core.Event) *User

NewFromEvents is a helper method that creates a new user from a series of events.

func (*User) Activate

func (u *User) Activate() error

Activate activates user.

func (*User) Apply

func (u *User) Apply(e core.Event, new bool)

Apply applies user events to the user aggregate.

func (*User) Deactivate

func (u *User) Deactivate() error

Deactivate deactivates user.

func (User) Events

func (u User) Events() []core.Event

Events returns the uncommitted events from the user aggregate.

func (*User) GetEmail

func (u *User) GetEmail() string

GetEmail returns the email of the user.

func (*User) GetEntity

func (u *User) GetEntity() core.Person

GetEntity returns the user root person core.

func (*User) GetID

func (u *User) GetID() uuid.UUID

GetID returns the user root ID.

func (*User) GetName

func (u *User) GetName() string

GetName returns the name of the user.

func (*User) GetPassword

func (u *User) GetPassword() string

GetPassword returns the hashed password of the user.

func (*User) IsActivated

func (u *User) IsActivated() bool

IsActivated returns whether the user is activated.

func (*User) UpdateEmail

func (u *User) UpdateEmail(email string) error

UpdateEmail updates the user's email.

func (*User) UpdateName

func (u *User) UpdateName(name string) error

UpdateName updates the user's name.

func (*User) UpdatePassword

func (u *User) UpdatePassword(password string) error

UpdatePassword updates the user's password.

func (User) Version

func (u User) Version() int

Version returns the last version of the aggregate before changes.

type UserActivated

type UserActivated struct {
	ID uuid.UUID `json:"id"`
}

UserActivated event.

func (UserActivated) EventName

func (e UserActivated) EventName() string

type UserDeactivated

type UserDeactivated struct {
	ID uuid.UUID `json:"id"`
}

UserDeactivated event.

func (UserDeactivated) EventName

func (e UserDeactivated) EventName() string

type UserEmailChanged

type UserEmailChanged struct {
	ID    uuid.UUID `json:"id"`
	Email string    `json:"email"`
}

UserEmailChanged event.

func (UserEmailChanged) EventName

func (e UserEmailChanged) EventName() string

type UserNameChanged

type UserNameChanged struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

UserNameChanged event.

func (UserNameChanged) EventName

func (e UserNameChanged) EventName() string

type UserPasswordChanged

type UserPasswordChanged struct {
	ID       uuid.UUID `json:"id"`
	Password string    `json:"password"`
}

UserPasswordChanged event.

func (UserPasswordChanged) EventName

func (e UserPasswordChanged) EventName() string

type UserRegistered

type UserRegistered struct {
	ID       uuid.UUID `json:"id"`
	Name     string    `json:"name"`
	Email    string    `json:"email"`
	Password string    `json:"password"`
}

UserRegistered event.

func (UserRegistered) EventName

func (e UserRegistered) EventName() string

type UserRepository

type UserRepository interface {
	GetByEmail(string) (*User, error)
	Add(*User) error
	Update(*User) error
}

UserRepository defines the interface for the user repository.

Jump to

Keyboard shortcuts

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