feat: Refactor User entity and datasource to use email and password hashing with salt
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package entities
|
||||
|
||||
import "errors"
|
||||
|
||||
var ErrUserAlreadyExists = errors.New("user already exists")
|
||||
var ErrUserNotFound = errors.New("user not found")
|
||||
var ErrActivityNotFound = errors.New("activity not found")
|
||||
var ErrActivityAlreadyExists = errors.New("activity already exists")
|
||||
var ErrInvalidPassword = errors.New("invalid password")
|
||||
var ErrInvalidEmail = errors.New("invalid email")
|
||||
var ErrInvalidUsername = errors.New("invalid username")
|
||||
var ErrInvalidRole = errors.New("invalid role")
|
||||
var ErrInvalidCompanyID = errors.New("invalid company id")
|
||||
var ErrInvalidHourlyRate = errors.New("invalid hourly rate")
|
||||
var ErrInvalidID = errors.New("invalid id")
|
||||
var ErrTimeEntryNotFound = errors.New("time entry not found")
|
||||
var ErrTimeEntryAlreadyExists = errors.New("time entry already exists")
|
||||
var ErrInvalidDuration = errors.New("invalid duration")
|
||||
var ErrInvalidDescription = errors.New("invalid description")
|
||||
var ErrInvalidStartTime = errors.New("invalid start time")
|
||||
var ErrInvalidEndTime = errors.New("invalid end time")
|
||||
var ErrInvalidBillable = errors.New("invalid billable")
|
||||
var ErrInvalidProjectID = errors.New("invalid project id")
|
||||
var ErrProjectNotFound = errors.New("project not found")
|
||||
var ErrProjectAlreadyExists = errors.New("project already exists")
|
||||
var ErrInvalidName = errors.New("invalid name")
|
||||
var ErrInvalidClientID = errors.New("invalid client id")
|
||||
var ErrClientNotFound = errors.New("client not found")
|
||||
var ErrClientAlreadyExists = errors.New("client already exists")
|
||||
var ErrInvalidAddress = errors.New("invalid address")
|
||||
var ErrInvalidPhone = errors.New("invalid phone")
|
||||
@@ -4,15 +4,15 @@ import "github.com/oklog/ulid/v2"
|
||||
|
||||
type User struct {
|
||||
EntityBase
|
||||
Username string
|
||||
Password string
|
||||
Email string
|
||||
Salt string
|
||||
Role string
|
||||
CompanyID int
|
||||
HourlyRate float64
|
||||
}
|
||||
|
||||
type UserCreate struct {
|
||||
Username string
|
||||
Email string
|
||||
Password string
|
||||
Role string
|
||||
CompanyID int
|
||||
@@ -21,7 +21,7 @@ type UserCreate struct {
|
||||
|
||||
type UserUpdate struct {
|
||||
ID ulid.ULID
|
||||
Username *string
|
||||
Email *string
|
||||
Password *string
|
||||
Role *string
|
||||
CompanyID *int
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
type UserDatasource interface {
|
||||
Get(ctx context.Context, id ulid.ULID) (*entities.User, error)
|
||||
Create(ctx context.Context, user *entities.User) error
|
||||
Update(ctx context.Context, user *entities.User) error
|
||||
Create(ctx context.Context, user *entities.User, passwordHash string, salt string) error
|
||||
Update(ctx context.Context, user *entities.User, passwordHash *string) error
|
||||
Delete(ctx context.Context, id ulid.ULID) error
|
||||
GetByUsername(ctx context.Context, username string) (*entities.User, error)
|
||||
GetByEmail(ctx context.Context, email string) (*entities.User, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user