user

package
v0.0.0-...-c74069a Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserAlreadyActivated error = errors.New("User already activated!")
View Source
var UserAlreadyExistError error = errors.New("User already exists")
View Source
var UserNotFound error = errors.New("User not found!")

Functions

This section is empty.

Types

type ActivationCodeDTO

type ActivationCodeDTO struct {
	Code  string `json:"code"`
	Email string `json:"email"`
}

type CustomClaims

type CustomClaims struct {
	UserType string `json:"userType"`
	jwt.StandardClaims
}

type EditorDTO

type EditorDTO struct {
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Phone     string `json:"phone"`
	Email     string `json:"email"`
	Password  string `json:"password"`
	UserType  string `json:"userType"`
}

type Handler

type Handler struct {
	Service Service
}

func NewHandler

func NewHandler(service Service) Handler

func (*Handler) ActivateUser

func (h *Handler) ActivateUser(c *fiber.Ctx) error

func (*Handler) DeleteUserHandler

func (h *Handler) DeleteUserHandler(c *fiber.Ctx) error

func (*Handler) GetAllStatsHandler

func (h *Handler) GetAllStatsHandler(c *fiber.Ctx) error

func (*Handler) LoginUserHandler

func (h *Handler) LoginUserHandler(c *fiber.Ctx) error

func (*Handler) RegisterEditorHandler

func (h *Handler) RegisterEditorHandler(c *fiber.Ctx) error

func (*Handler) RegisterUserHandler

func (h *Handler) RegisterUserHandler(c *fiber.Ctx) error

func (*Handler) SetupApp

func (h *Handler) SetupApp(app *fiber.App)

type Page

type Page struct {
	Number        int `json:"number"`
	Size          int `json:"size",omitempty`
	TotalElements int `json:"totalElements",omitempty"`
	TotalPages    int `json:"totalPages",omitempty"`
}

type Repository

type Repository struct {
	MongoClient *mongo.Client
}

func NewRepository

func NewRepository(uri string) Repository

func (*Repository) ActivateUser

func (r *Repository) ActivateUser(userID string) (*User, error)

func (*Repository) AddActivationCode

func (r *Repository) AddActivationCode(email, activationCode string) error

func (*Repository) DeleteActivationCode

func (r *Repository) DeleteActivationCode(code string) error

func (*Repository) DeleteUser

func (r *Repository) DeleteUser(userID string) error

func (*Repository) GetCodesCount

func (r *Repository) GetCodesCount() (int64, error)

func (*Repository) GetCoinsCount

func (r *Repository) GetCoinsCount() (int64, error)

func (*Repository) GetFavListsCount

func (r *Repository) GetFavListsCount() (int64, error)

func (*Repository) GetNewsCount

func (r *Repository) GetNewsCount() (int64, error)

func (*Repository) GetSpotsCount

func (r *Repository) GetSpotsCount() (int64, error)

func (*Repository) GetTransactionsCount

func (r *Repository) GetTransactionsCount() (int64, error)

func (*Repository) GetUser

func (r *Repository) GetUser(userID string) (*User, error)

func (*Repository) GetUserByEmail

func (r *Repository) GetUserByEmail(email string) (*User, error)

func (*Repository) GetUsers

func (r *Repository) GetUsers(page, size int) ([]User, int, error)

func (*Repository) RegisterUser

func (r *Repository) RegisterUser(user User) (*User, error)

type Service

type Service struct {
	Repository Repository
}

func NewService

func NewService(repository Repository) Service

func (*Service) ActivateUser

func (s *Service) ActivateUser(email, code string) (*Token, *User, error)

func (*Service) DeleteUser

func (s *Service) DeleteUser(userID string) error

func (*Service) GetAllStats

func (s *Service) GetAllStats() (*Stats, error)

func (*Service) GetUsersPageableResponse

func (s *Service) GetUsersPageableResponse(pageNumber, size int) (*UsersPageableResponse, error)

func (*Service) LoginUser

func (s *Service) LoginUser(userCredentialsDTO UserCredentialsDTO) (*Token, *fiber.Cookie, error)

func (*Service) RegisterEditor

func (s *Service) RegisterEditor(editorDTO EditorDTO) (*User, error)

func (*Service) RegisterUser

func (s *Service) RegisterUser(userDTO UserDTO) (*User, error)

type Stats

type Stats struct {
	CodesCount        int64 `json:"codesCount"`
	CoinsCount        int64 `json:"coinsCount"`
	FavListCount      int64 `json:"favListCount"`
	NewsCount         int64 `json:"newsCount"`
	SpotsCount        int64 `json:"spotsCount"`
	TransactionsCount int64 `json:"transactionsCount"`
}

type Token

type Token struct {
	Token string `json:"token"`
}

type User

type User struct {
	ID              string    `json:"id" bson:"id"`
	FirstName       string    `json:"firstName" bson:"firstName"`
	LastName        string    `json:"lastName" bson:"lastName""`
	Email           string    `json:"email" bson:"email""`
	Phone           string    `json:"phone" bson:"phone""`
	Password        string    `json:"password" bson:"password"`
	IsEmailActivate bool      `json:"isEmailActivate" bson:"isEmailActivate"`
	UserType        string    `json:"userType" bson:"userType"`
	CreatedAt       time.Time `json:"createdAt" bson:"createdAt"`
}

type UserCredentialsDTO

type UserCredentialsDTO struct {
	Email    string `json:"email""`
	Password string `json:"password"`
}

type UserDTO

type UserDTO struct {
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	Phone     string `json:"phone"`
	Email     string `json:"email"`
	Password  string `json:"password"`
}

type UsersPageableResponse

type UsersPageableResponse struct {
	Users []User `json:"users"`
	Page  Page   `json:"page"`
}

Jump to

Keyboard shortcuts

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