service

package
v0.0.0-...-b88e834 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

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

func NewAuthService

func NewAuthService(repo repository.User) *AuthService

func (*AuthService) CreateUser

func (s *AuthService) CreateUser(username, email, password string) (int, error)

func (*AuthService) GenerateTokenPair

func (s *AuthService) GenerateTokenPair(email, password string) (Tokens, error)

func (*AuthService) ParseToken

func (s *AuthService) ParseToken(token string) (int, error)

type Authorization

type Authorization interface {
	CreateUser(username, email, password string) (int, error)
	GenerateTokenPair(email, password string) (Tokens, error)
	ParseToken(token string) (int, error)
}

type Deps

type Deps struct {
	Repos *repository.Repository
}

type Service

type Service struct {
	Authorization
	User
}

func NewService

func NewService(deps *Deps) *Service

type TokenClaims

type TokenClaims struct {
	jwt.StandardClaims
	UserId int `json:"user_id"`
}

type Tokens

type Tokens map[string]string

type User

type User interface {
	GetUser(id int) (entity.User, error)
	GetAll() ([]entity.User, error)
}

type UserService

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

func NewUserService

func NewUserService(repo repository.User) *UserService

func (UserService) GetAll

func (u UserService) GetAll() ([]entity.User, error)

func (UserService) GetUser

func (u UserService) GetUser(id int) (entity.User, error)

Jump to

Keyboard shortcuts

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