authservice

package
v0.0.0-...-ffefdcf Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: GPL-3.0 Imports: 9 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(
	userStorage UserStorage,
	tokenStorage TokenStorage,
	jwtKey string,
) *AuthService

func (*AuthService) Login

func (s *AuthService) Login(
	ctx context.Context,
	email string,
	password string,
	identifyData entities.UserIdentifyData,
) (entities.Tokens, error)

Move this to some service that implement registry pattern (consul).

func (*AuthService) RefreshToken

func (s *AuthService) RefreshToken(
	ctx context.Context,
	refreshToken string,
	identifyData entities.UserIdentifyData,
) (entities.Tokens, error)

type TokenStorage

type TokenStorage interface {
	CreateRefreshToken(ctx context.Context, token entities.RefreshToken) error
	GetAllActiveRefreshTokens(ctx context.Context, userID int) ([]entities.RefreshToken, error)
	DeactivateTokenByIDs(ctx context.Context, tokenIDs []int) error
	GetToken(ctx context.Context, refreshToken string) (entities.RefreshToken, error)
}

type UserStorage

type UserStorage interface {
	GetUserByEmail(ctx context.Context, email string) (entities.User, error)
	GetUserByID(ctx context.Context, id int) (entities.User, error)
}

Jump to

Keyboard shortcuts

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