users

package
v0.0.0-...-3d9bb29 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetProfileModel

type GetProfileModel struct {
	ID int
}

type LoginModel

type LoginModel struct {
	Email    string `json:"email" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type RegisterModel

type RegisterModel struct {
	Email     string `json:"email" validate:"email" binding:"required"`
	Password  string `json:"password" binding:"required"`
	FirstName string `json:"firstName" binding:"required"`
	LastName  string `json:"lastName" binding:"required"`
}

type User

type User struct {
	gorm.Model
	Email     string   `gorm:"size:255;not null;uniqueIndex:idx_email"`
	Password  *string  `gorm:"size:255;not null"`
	FirstName string   `gorm:"size:255;not null"`
	LastName  string   `gorm:"size:255;not null"`
	Role      UserRole `gorm:"size:255;not null"`
}

type UserHandler

type UserHandler struct {
	Usecase UserUseCase
}

func ConstructUserHandler

func ConstructUserHandler(router *gin.Engine, usecase UserUseCase, jwtAuth authentication.IJwtAuth) UserHandler

func (*UserHandler) GetProfile

func (u *UserHandler) GetProfile(c *gin.Context)

@Summary Get profile @Description Get detailed user profile @Tags accounts @Produce json @Router /api/v1/user/me [get] @Security JwtAuth

func (*UserHandler) Login

func (u *UserHandler) Login(c *gin.Context)

login godoc @Summary Login @Description Authenticate a user to get access token @Tags accounts @Accept json @Produce json @Param body body string true "Login body" @Router /api/v1/user/login [post] @Security BasicAuth

func (*UserHandler) Register

func (u *UserHandler) Register(c *gin.Context)

@Summary Register new account @Description Register new account @Tags accounts @Accept json @Produce json @Param body body string true "Register body" @Router /api/v1/user/register [post] @Security BasicAuth

type UserLoginDto

type UserLoginDto struct {
	Email       string `json:"email"`
	FirstName   string `json:"firstName"`
	LastName    string `json:"lastName"`
	AccessToken string `json:"accessToken"`
}

type UserProfileDto

type UserProfileDto struct {
	ID        uint      `json:"id"`
	Email     string    `json:"email"`
	FirstName string    `json:"firstName"`
	LastName  string    `json:"lastName"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type UserRole

type UserRole string
const (
	ADMIN       UserRole = "ADMIN"
	CONTRIBUTOR UserRole = "CONTRIBUTOR"
)

type UserUseCase

type UserUseCase interface {
	Register(c context.Context, model RegisterModel) utils.Response
	Login(c context.Context, model LoginModel) utils.Response
	GetProfile(c context.Context, model GetProfileModel) utils.Response
}

func ConstructUserUseCase

func ConstructUserUseCase(db *gorm.DB, jwtAuth authentication.IJwtAuth) UserUseCase

type UserUseCaseImpl

type UserUseCaseImpl struct {
	Database *gorm.DB
	JwtAuth  authentication.IJwtAuth
}

func (*UserUseCaseImpl) GetProfile

func (u *UserUseCaseImpl) GetProfile(c context.Context, model GetProfileModel) utils.Response

func (*UserUseCaseImpl) Login

func (*UserUseCaseImpl) Register

Jump to

Keyboard shortcuts

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