auth_module

package module
v0.0.0-...-2c61968 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: MIT Imports: 11 Imported by: 0

README

test-module

Documentation

Index

Constants

View Source
const (
	ErrInvalidParameterValue = "invalid_parameter_value"
	ErrUnknownError          = "unknown_error"

	ErrEmailAlreadyTaken = "email_already_taken"
)

Variables

This section is empty.

Functions

func NewMongoDBConn

func NewMongoDBConn(cfg *Config) (*mongo.Database, error)

func NewUserMongoRepo

func NewUserMongoRepo(db *mongo.Database) *userRepo

func NewUserUC

func NewUserUC(userRepo MongoRepository) *userUC

func ValidateStruct

func ValidateStruct(ctx context.Context, s interface{}) error

Types

type Config

type Config struct {
	MongoDB MongoDBConfig
}

type ErrorResponse

type ErrorResponse struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

type MongoDBConfig

type MongoDBConfig struct {
	URI    string
	DBName string
}

type MongoRepository

type MongoRepository interface {
	Create(ctx context.Context, user *User) error
	FindByEmail(ctx context.Context, email string) (*User, error)
}

type SignUpUserRequest

type SignUpUserRequest struct {
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required,gte=6"`
}

type SignUpUserResponse

type SignUpUserResponse struct {
	Success bool `json:"success"`
}

type UseCase

type UseCase interface {
	SignUpUser(ctx context.Context, req *SignUpUserRequest) (*SignUpUserResponse, *ErrorResponse)
}

func NewApp

func NewApp(cfg *Config) (UseCase, error)

type User

type User struct {
	ID       primitive.ObjectID `bson:"_id"`
	Email    string             `bson:"email"`
	Password string             `bson:"password"`
}

func (*User) ComparePasswords

func (u *User) ComparePasswords(password string) error

func (*User) HashPassword

func (u *User) HashPassword() error

func (*User) PrepareCreateUser

func (u *User) PrepareCreateUser() error

Jump to

Keyboard shortcuts

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