service

package
v0.0.0-...-1bcb742 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bcrypt

type Bcrypt interface {
	HashPassword(password string) (string, error)
	CompareHashAndPassword(hash, password string) (bool, error)
}

type Cache

type Cache interface {
	SetAccessToken(ctx context.Context, userID, token string) error
	SetRefreshToken(ctx context.Context, userID, token string) error
	CheckAccessToken(ctx context.Context, userID, token string) (bool, error)
	CheckRefreshToken(ctx context.Context, userID, token string) (bool, error)
	RemoveAccessToken(ctx context.Context, userID, token string) error
	RemoveRefreshToken(ctx context.Context, userID, token string) error
}

type Repository

type Repository interface {
	GetUserByID(ctx context.Context, userID string) (*domain.User, error)
	GetUserByName(ctx context.Context, name string) (*domain.User, error)
	GetUserByEmail(ctx context.Context, email string) (*domain.User, error)
	AddUser(ctx context.Context, name, email, password string) (string, error)
	GetUsersTotalCount(ctx context.Context) (int, error)
	GetUsers(ctx context.Context, skip, limit int) ([]domain.User, error)
}

type Service

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

func NewService

func NewService(
	repo Repository,
	cache Cache,
	b Bcrypt,
	v Validator,
	t Tokener,
) *Service

func (*Service) CheckAccessToken

func (s *Service) CheckAccessToken(ctx context.Context, accessToken string) error

func (*Service) GetUserByID

func (s *Service) GetUserByID(ctx context.Context, userID string) (domain.User, error)

func (*Service) GetUsersList

func (s *Service) GetUsersList(ctx context.Context, skip, limit int) ([]domain.User, int, error)

func (*Service) LogOut

func (s *Service) LogOut(ctx context.Context, accessToken, refreshToken string) error

func (*Service) Refresh

func (s *Service) Refresh(ctx context.Context, rt string) (domain.Tokens, error)

func (*Service) SignIn

func (s *Service) SignIn(ctx context.Context, email, password string) (domain.Tokens, error)

func (*Service) SignUp

func (s *Service) SignUp(ctx context.Context, name, email, password, repeatedPassword string) (domain.Tokens, error)

type Tokener

type Tokener interface {
	SignAccessToken(userID string, role uint32) (string, error)
	SignRefreshToken(userID string) (string, error)
	ValidateAccessToken(token string) (string, uint32, error)
	ValidateRefreshToken(token string) (string, error)
}

type Validator

type Validator interface {
	ValidateSignUp(email, name, password, repeatedPassword string) error
	ValidateSignIn(email, password string) error
	ValidateGetUserByID(userID string) error
	ValidateGetUsersList(skip, limit int) error
}

Jump to

Keyboard shortcuts

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