users

package
v0.0.0-...-0eac02a Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrInvalidEmail

func NewErrInvalidEmail() shared.AppError

func NewErrInvalidPassword

func NewErrInvalidPassword() shared.AppError

func NewErrInvalidUsername

func NewErrInvalidUsername() shared.AppError

func NewPasswordValidator

func NewPasswordValidator(passwordPolicy *shared.FeatureConfig) shared.Validator

Types

type CreateDTO

type CreateDTO struct {
	Username string `json:"username" yaml:"username"`
	Name     string `json:"name" yaml:"name"`
	Email    string `json:"email" yaml:"email"`
	Password string `json:"password" yaml:"password"`
}

func (*CreateDTO) LogFields

func (dto *CreateDTO) LogFields() log.Fields

func (*CreateDTO) ToEntity

func (dto *CreateDTO) ToEntity() User

type CreateUserService

type CreateUserService interface {
	CreateUser(ctx context.Context, ctrDTO *User) error
}

func NewCreateUserService

func NewCreateUserService(userRepo Repository) CreateUserService

type DiProvider

type DiProvider struct {
	Repos    Repositories
	Services Services
	Facade   Facade
}

func NewDiProvider

func NewDiProvider(db shared.DBConnection, features *shared.FeaturesConfig) DiProvider

type Facade

type Facade interface {
	Create(ctx context.Context, newUser *CreateDTO) (*User, error)
	Update(ctx context.Context, user *User) (*User, error)
	Delete(ctx context.Context, userId uuid.UUID) error
	UpdatePassword(ctx context.Context, userId uuid.UUID, password *UpdatePasswordDTO) error
	List(ctx context.Context, params ListParams) ([]User, error)
	Get(ctx context.Context, userId uuid.UUID) (*User, error)
	GetByUsername(ctx context.Context, userId string) (*User, error)
	GetByAnyId(ctx context.Context, sid string) (*User, error)
}

func NewUsersFacade

func NewUsersFacade(users Repository, secrets SecretsRepository, services Services, features *shared.FeaturesConfig) Facade

type FindQuery

type FindQuery struct {
	repos.PaginationQuery
	Id       uuid.UUID
	Username string
	Email    string
	AnyId    string
}

type FindService

type FindService interface {
	Find(ctx context.Context, params FindQuery) ([]User, error)
	FindOne(ctx context.Context, params FindQuery) (*User, error)
}

func NewFindUsersService

func NewFindUsersService(usersRepo Repository) FindService

type ListParams

type ListParams struct {
	Limit  int
	Offset int
}

type ListUserDTO

type ListUserDTO struct {
	ID       uuid.UUID `json:"id" yaml:"id"`
	Username string    `json:"username" yaml:"state"`
	Email    string    `json:"email" yaml:"email"`
}

func ConvertModelsToList

func ConvertModelsToList(list []User) []ListUserDTO

type PasswordService

type PasswordService interface {
	CheckPassword(ctx context.Context, user *User, provided string) (bool, error)
	SetPassword(ctx context.Context, user *User, provided string) error
}

func NewPasswordService

func NewPasswordService(usersRepo Repository) PasswordService

type PasswordServiceImpl

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

func (*PasswordServiceImpl) CheckPassword

func (s *PasswordServiceImpl) CheckPassword(ctx context.Context, user *User, provided string) (bool, error)

func (*PasswordServiceImpl) SetPassword

func (s *PasswordServiceImpl) SetPassword(ctx context.Context, user *User, password string) error

type PasswordStrengthValidator

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

func (*PasswordStrengthValidator) FieldName

func (v *PasswordStrengthValidator) FieldName() string

func (*PasswordStrengthValidator) Validate

func (v *PasswordStrengthValidator) Validate(data interface{}) shared.ValidationResult

type Repositories

type Repositories struct {
	Users   Repository
	Secrets SecretsRepository
}

type Repository

type Repository interface {
	Create(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User) error
	Delete(ctx context.Context, user *User) error
	Query(ctx context.Context, query FindQuery) ([]User, error)
	QueryOne(ctx context.Context, query FindQuery) (*User, error)
}

func NewUsersRepositoryDB

func NewUsersRepositoryDB(db *gorm.DB) Repository

type SecretModel

type SecretModel struct {
	ID        uuid.UUID  `gorm:"type:uuid;primary_key;"`
	UserID    uuid.UUID  `gorm:"type:varchar"`
	Value     string     `gorm:"type:varchar"`
	Name      string     `gorm:"type:varchar"`
	CreatedAt time.Time  `gorm:"type:timestamp"`
	UpdatedAt time.Time  `gorm:"type:timestamp"`
	ExpiresAt *time.Time `gorm:"type:timestamp"`
}

func (SecretModel) IsExpired

func (s SecretModel) IsExpired() bool

func (SecretModel) TableName

func (SecretModel) TableName() string

type SecretQuery

type SecretQuery struct {
	repos.PaginationQuery
	Id     uuid.UUID
	UserId uuid.UUID
}

type SecretsRepository

type SecretsRepository interface {
	Create(ctx context.Context, secret *SecretModel) error
	Update(ctx context.Context, secret *SecretModel) error
	Delete(ctx context.Context, secret *SecretModel) error
	Query(ctx context.Context, query SecretQuery) ([]SecretModel, error)
	QueryOne(ctx context.Context, query SecretQuery) (*SecretModel, error)
}

func NewSecretsRepositoryDB

func NewSecretsRepositoryDB(DB *gorm.DB) SecretsRepository

type Services

type Services struct {
	Find     FindService
	Password PasswordService
}

type UpdateDTO

type UpdateDTO struct {
	Username string `json:"username" yaml:"username"`
	Name     string `json:"name" yaml:"name"`
	Email    string `json:"email" yaml:"email"`
}

func (*UpdateDTO) ToEntity

func (dto *UpdateDTO) ToEntity() User

type UpdatePasswordDTO

type UpdatePasswordDTO struct {
	CurrentPassword string `json:"current_password"`
	NewPassword     string `json:"new_password"`
}

type User

type User struct {
	ID        uuid.UUID  `gorm:"type:uuid;primary_key;"`
	CreatedAt time.Time  `gorm:"type:timestamp"`
	UpdatedAt time.Time  `gorm:"type:timestamp"`
	DeletedAt *time.Time `gorm:"type:timestamp"`
	Username  string
	Password  string
	Name      string
	Email     string
	State     string
	UserType  string `gorm:"column:user_type"`
}

func (*User) CheckPassword

func (user *User) CheckPassword(password string) bool

func (*User) LogFields

func (user *User) LogFields() log.Fields

func (*User) SetPassword

func (user *User) SetPassword(password string) error

func (User) TableName

func (User) TableName() string

func (*User) ToDTO

func (user *User) ToDTO() *UserDTO

type UserDTO

type UserDTO struct {
	ID        uuid.UUID `json:"id" yaml:"id"`
	Username  string    `json:"username" yaml:"username"`
	Name      string    `json:"name" yaml:"name"`
	Email     string    `json:"email" yaml:"email"`
	State     string    `json:"state" yaml:"state"`
	CreatedAt time.Time `json:"created_at" yaml:"created_at"`
	UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
}

func ConvertModelToDTO

func ConvertModelToDTO(user *User) *UserDTO

Jump to

Keyboard shortcuts

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