user

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAccessToken

func CreateAccessToken(id int, uid uuid.UUID) (string, error)

func JWTAuth

func JWTAuth(authenticator Authenticator) gin.HandlerFunc

Types

type AuthClaims

type AuthClaims struct {
	User   int       `json:"user"`
	UUID   uuid.UUID `json:"uuid"`
	Random string    `json:"rnd"`
	jwt.RegisteredClaims
}

type Authenticator

type Authenticator interface {
	ValidateAccessToken(accessToken string) (bool, error)
	ExtractUserIDFromToken(accessToken string) (int, uuid.UUID, error)
	ValidateUser(id int, uid uuid.UUID) (bool, error)
	ValidateUserAndGetDetail(id int, uid uuid.UUID) (bool, *repository.User, error)
}

type AuthenticatorImpl

type AuthenticatorImpl struct {
	// contains filtered or unexported fields
}

func NewAuthenticatorImpl

func NewAuthenticatorImpl(userRepository repository.UserRepository, logger *zap.SugaredLogger) *AuthenticatorImpl

func (*AuthenticatorImpl) ExtractUserIDFromToken

func (impl *AuthenticatorImpl) ExtractUserIDFromToken(accessToken string) (int, uuid.UUID, error)

func (*AuthenticatorImpl) ValidateAccessToken

func (impl *AuthenticatorImpl) ValidateAccessToken(accessToken string) (bool, error)

func (*AuthenticatorImpl) ValidateUser

func (impl *AuthenticatorImpl) ValidateUser(id int, uid uuid.UUID) (bool, error)

func (*AuthenticatorImpl) ValidateUserAndGetDetail added in v1.7.1

func (impl *AuthenticatorImpl) ValidateUserAndGetDetail(id int, uid uuid.UUID) (bool, *repository.User, error)

type UserDto

type UserDto struct {
	ID           int       `json:"-"`
	SID          string    `json:"userId,omitempty"`
	UID          uuid.UUID `json:"-"`
	Nickname     string    `json:"nickname,omitempty"`
	Password     string    `json:"-"`
	Email        string    `json:"email,omitempty"`
	Language     string    `json:"language,omitempty"`
	IsSubscribed bool      `json:"-"`
	CreatedAt    time.Time `json:"-"`
	UpdatedAt    time.Time `json:"-"`
}

type UserService

type UserService interface {
	CreateUser(userDto UserDto) (UserDto, error)
	UpdateUser(userDto UserDto) (UserDto, error)
	FindUserByEmail(email string) (UserDto, error)
	GetUser(id int) (UserDto, error)
	GetToken(id int, uid uuid.UUID) (string, error)
	GenerateVerificationCode(email, usage string) (string, error)
	ValidateVerificationCode(vCode, vToken, email, usage string) (bool, error)
	SendSubscriptionEmail(email string) error
}

type UserServiceImpl

type UserServiceImpl struct {
	// contains filtered or unexported fields
}

func NewUserServiceImpl

func NewUserServiceImpl(userRepository repository.UserRepository, logger *zap.SugaredLogger,
	smtpServer smtp.SMTPServer) *UserServiceImpl

func (*UserServiceImpl) CreateUser

func (impl *UserServiceImpl) CreateUser(userDto UserDto) (UserDto, error)

func (*UserServiceImpl) FindUserByEmail

func (impl *UserServiceImpl) FindUserByEmail(email string) (UserDto, error)

func (*UserServiceImpl) GenerateVerificationCode

func (impl *UserServiceImpl) GenerateVerificationCode(email, usage string) (string, error)

func (*UserServiceImpl) GetToken

func (impl *UserServiceImpl) GetToken(id int, uid uuid.UUID) (string, error)

func (*UserServiceImpl) GetUser

func (impl *UserServiceImpl) GetUser(id int) (UserDto, error)

func (*UserServiceImpl) SendSubscriptionEmail

func (impl *UserServiceImpl) SendSubscriptionEmail(email string) error

func (*UserServiceImpl) UpdateUser

func (impl *UserServiceImpl) UpdateUser(userDto UserDto) (UserDto, error)

func (*UserServiceImpl) ValidateVerificationCode

func (impl *UserServiceImpl) ValidateVerificationCode(vCode, vToken, email, usage string) (bool, error)

Jump to

Keyboard shortcuts

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