Documentation ¶
Overview ¶
package user holds user domain logic
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrEmailInvalid is when given email is not a valid email. ErrEmailInvalid = apperror.NewBadRequest("email is not a valid email") // ErrPasswordInvalid is when given password is not a valid password. ErrPasswordInvalid = apperror.NewBadRequest("password is not a valid password") )
Functions ¶
This section is empty.
Types ¶
type EmailAddress ¶
type EmailAddress string
EmailAddress is an email address.
func (EmailAddress) IsValid ¶
func (e EmailAddress) IsValid() *apperror.AppError
IsValid returns error if string is not valid email.
type Password ¶
type Password string
Password is an email address.
func (Password) ComparePassword ¶
ComparePassword verifies if password matched with hash
func (*Password) HashAndSalt ¶
HashAndSalt hash and salt the password
type Repository ¶
type Repository interface { NewId() string InsertOne(ctx context.Context, u *User) *apperror.AppError UpdateOne(ctx context.Context, u *User) *apperror.AppError FindOne(ctx context.Context, id string) (*User, *apperror.AppError) FindByEmail(ctx context.Context, email EmailAddress) (*User, *apperror.AppError) }
Repository allows persistent operations for User
type User ¶
type User struct { ID string `json:"id,omitempty" bson:"_id,omitempty"` Email EmailAddress `json:"email,omitempty" bson:"email"` Hash Password `json:"hash,omitempty" bson:"hash"` CreatedAt time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"` UpdatedAt time.Time `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"` }
User aggregate root
Click to show internal directories.
Click to hide internal directories.