user

package
v0.0.0-...-23038bb Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValidationFailed                    = errors.New("Validation failed")
	ErrValidationFailedCode                = "USER_0001"
	ErrDuplicateEmail                      = errors.New("Email is already taken")
	ErrDuplicateEmailCode                  = "USER_0002"
	ErrInvalidCredentials                  = errors.New("Invalid credentials")
	ErrInvalidCredentialsCode              = "USER_0003"
	ErrEmailIsNotVerified                  = errors.New("Please verify your email first")
	ErrEmailIsNotVerifiedCode              = "USER_0004"
	ErrUserIsNotActive                     = errors.New("User is already deadactivated her/him account")
	ErrUserIsNotActiveCode                 = "USER_0005"
	ErrEmailVerificationExpired            = errors.New("Email verification link is expired")
	ErrEmailVerificationExpiredCode        = "USER_0006"
	ErrEmailVerificationAlreadyClaimed     = errors.New("Email verification is already claimed")
	ErrEmailVerificationAlreadyClaimedCode = "USER_0007"
	ErrEmailIsAlreadyVerified              = errors.New("Email is already verified")
	ErrEmailIsAlreadyVerifiedCode          = "USER_0008"
)

Functions

func RegisterHandler

func RegisterHandler(r *gin.Engine, service Service)

RegisterHandler ...

Types

type CreateUserDto

type CreateUserDto struct {
	Email    string `form:"email"`
	Password string `form:"password"`
}

type CredentialsDto

type CredentialsDto struct {
	Email    string `form:"email"`
	Password string `form:"password"`
}

type Repository

type Repository interface {
	Create(entity.User) (entity.User, error)
	// Delete(id string) error
	FindOneByEmail(email string) (entity.User, error)
	FindOneById(id string) (entity.User, error)
	CreateEmailVerification(id string) (string, error)
	FindOneToken(token string) (entity.EmailVerification, error)
	FindTokenByUserId(id string) (entity.EmailVerification, error)
	RenewToken(id string) (entity.EmailVerification, error)
	VerifyEmail(userId, tokenId string) error
}

func NewRepository

func NewRepository(db *sql.DB) Repository

type ResendEmailVerificationDto

type ResendEmailVerificationDto struct {
	Email string `form:"email"`
}

type Service

type Service interface {
	Create(entity.User) (entity.User, error)
	FindOneByEmail(email string) (entity.User, error)
	GenerateJWT(user entity.User) (string, error)
	CreateEmailVerification(id string) (string, error)
	FindOneToken(token string) (entity.EmailVerification, error)
	VerifyEmail(userId, tokenId string) error
	FindTokenByUserId(id string) (entity.EmailVerification, error)
	RenewToken(id string) (entity.EmailVerification, error)
}

func NewService

func NewService(repo Repository) Service

Jump to

Keyboard shortcuts

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