domain

package
v0.0.0-...-ae75a06 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 3 Imported by: 8

Documentation

Index

Constants

View Source
const (
	UserErrorUsernameEmptyCode = iota
	UserErrorInvalidUsernameLengthCode
	UserErrorPasswordEmptyCode
	UserErrorWrongPasswordCode
	UserErrorUsernameExistsCode
	UserErrorPasswordConfirmationNotMatchCode
	UserChangePasswordErrorWrongOldPasswordCode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PasswordChanged

type PasswordChanged struct {
	UID         uuid.UUID
	NewPassword []byte
	DateChanged time.Time
}

type User

type User struct {
	UID         uuid.UUID
	Username    string
	Password    []byte
	ClientID    string
	CreatedDate time.Time
	LastUpdated time.Time

	// Events
	Version            int
	UncommittedChanges []interface{}
}

func CreateUser

func CreateUser(userService UserService, username, password, confirmPassword string) (*User, error)

func (*User) ChangePassword

func (u *User) ChangePassword(oldPassword, newPassword, newConfirmPassword string) error

func (*User) IsPasswordValid

func (u *User) IsPasswordValid(password string) (bool, error)

func (*User) TrackChange

func (u *User) TrackChange(event interface{})

func (*User) Transition

func (u *User) Transition(event interface{})

type UserCreated

type UserCreated struct {
	UID         uuid.UUID
	Username    string
	Password    []byte
	CreatedDate time.Time
	LastUpdated time.Time
}

type UserError

type UserError struct {
	Code int
}

UserError is a custom error from Go built-in error

func (UserError) Error

func (e UserError) Error() string

type UserService

type UserService interface {
	FindUserByUsername(username string) (UserServiceResult, error)
}

type UserServiceResult

type UserServiceResult struct {
	UID      uuid.UUID
	Username string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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