user

package
v0.0.0-...-d868565 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var I18nMessages = messages{
	EmailEmpty:                "error_user_email_empty",
	NotFound:                  "error_user_not_found",
	Deleted:                   "error_user_deleted",
	Failed:                    "error_user_failed",
	AlreadyExists:             "error_user_already_exists",
	InvalidPassword:           "error_user_invalid_password",
	InvalidUUID:               "error_user_invalid_uuid",
	RefreshTokenNotAvailable:  "error_user_refresh_token_not_available",
	TwoFactorStarted:          "error_user_two_factor_started",
	TokenExpired:              "error_user_token_expired",
	AlreadyVerified:           "error_user_already_verified",
	NotVerified:               "error_user_not_verified",
	TokenNotExpired:           "error_user_token_not_expired",
	AuthRegisteredMailSubject: "auth_registered_mail_subject",
	AnErrorOccurred:           "error_user_an_error_occurred",
	SubjectVerificationCode:   "subject_verification_code",
	SMSVerificationCode:       "sms_verification_code",
}

Functions

This section is empty.

Types

type Entity

type Entity struct {
	UUID             string     `json:"uuid" bson:"_id,omitempty"`
	Email            string     `json:"email" bson:"email"`
	Phone            string     `json:"phone" bson:"phone"`
	Roles            []string   `json:"roles" bson:"roles"`
	Password         []byte     `json:"password,omitempty" bson:"password,omitempty"`
	TwoFactorEnabled bool       `json:"twoFactorEnabled" bson:"two_factor_enabled"`
	IsActive         bool       `json:"isActive" bson:"is_active"`
	IsDeleted        bool       `json:"isDeleted" bson:"is_deleted"`
	IsVerified       bool       `json:"isVerified" bson:"is_verified"`
	VerifyToken      string     `json:"emailVerifyToken" bson:"email_verify_token"`
	CreatedAt        time.Time  `json:"createdAt" bson:"created_at"`
	UpdatedAt        time.Time  `json:"updatedAt" bson:"updated_at"`
	DeletedAt        *time.Time `json:"deletedAt" bson:"deleted_at"`
}

func (*Entity) CleanPassword

func (e *Entity) CleanPassword()

func (*Entity) SetPassword

func (e *Entity) SetPassword(password []byte)

func (*Entity) ToListDto

func (e *Entity) ToListDto() ListDto

type Errors

type Errors interface {
	NotFound(email string) *i18np.Error
	AlreadyExists(email string) *i18np.Error
	Failed(operation string) *i18np.Error
	InvalidPassword() *i18np.Error
	AnErrorOccurred() *i18np.Error
	InvalidUUID() *i18np.Error
	RefreshTokenNotAvailable() *i18np.Error
	TwoFactorStarted(token string) *i18np.Error
	TokenExpired(p interface{}) *i18np.Error
	AlreadyVerified() *i18np.Error
	NotVerified(p interface{}) *i18np.Error
	Deleted() *i18np.Error
	TokenNotExpired() *i18np.Error
}

type EventConfig

type EventConfig struct {
	Publisher events.Publisher
	Topics    config.Topics
	Urls      config.Urls
	I18n      *i18np.I18n
}

type Events

type Events interface {
	SendVerification(event SendVerificationEvent)
}

func NewEvents

func NewEvents(cnf EventConfig) Events

type Factory

type Factory struct {
	Errors Errors
}

func NewFactory

func NewFactory() Factory

func (Factory) IsZero

func (f Factory) IsZero() bool

func (Factory) New

func (f Factory) New(email string, password []byte, token string) *Entity

func (Factory) Unmarshal

func (f Factory) Unmarshal(uuid string, email string, isActive bool) *Entity

func (Factory) Validate

func (f Factory) Validate(u *Entity) *i18np.Error

type FilterEntity

type FilterEntity struct {
	Query string `query:"q,omitempty" validate:"omitempty,max=500"`
}

type ListDto

type ListDto struct{}

type Repo

type Repo interface {
	GetByUUID(ctx context.Context, uuid string) (*Entity, *i18np.Error)
	GetByEmail(ctx context.Context, email string) (*Entity, *i18np.Error)
	GetByToken(ctx context.Context, token string) (*Entity, *i18np.Error)
	CheckEmail(ctx context.Context, email string) (bool, *i18np.Error)
	EnableTwoFactor(ctx context.Context, uuid string) *i18np.Error
	DisableTwoFactor(ctx context.Context, uuid string) *i18np.Error
	Create(ctx context.Context, entity *Entity) (*Entity, *i18np.Error)
	SetToken(ctx context.Context, email string, token string) *i18np.Error
	Verify(ctx context.Context, token string) *i18np.Error
	AddRoles(ctx context.Context, uuid string, roles []string) *i18np.Error
	RemoveRoles(ctx context.Context, uuid string, roles []string) *i18np.Error
	Delete(ctx context.Context, uuid string) *i18np.Error
	Recover(ctx context.Context, uuid string) *i18np.Error
	SetPassword(ctx context.Context, uuid string, password []byte) *i18np.Error
	List(ctx context.Context, filter FilterEntity, listConf list.Config) (*list.Result[*Entity], *i18np.Error)
}

func NewRepo

func NewRepo(collection *mongo.Collection, factory Factory) Repo

type SendVerificationEvent

type SendVerificationEvent struct {
	Email string `json:"email"`
	Token string `json:"token"`
	Lang  string
}

type TwoFactor

type TwoFactor struct {
	TempToken string `json:"tempToken"`
	Verify    bool   `json:"verify"`
}

Jump to

Keyboard shortcuts

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