biz

package
v0.0.0-...-4c0fd1a Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound      = status.Errorf(codes.NotFound, "reason: %v", v1.ErrorReason_USER_NOT_FOUND.String())
	ErrUserAlreadyExists = status.Errorf(codes.AlreadyExists, "reason: %v", v1.ErrorReason_USER_ALREADY_EXISTS.String())
	ErrWrongPassword     = status.Errorf(codes.PermissionDenied, "reason: %v", v1.ErrorReason_WRONG_PASSWORD.String())
	ErrInvalidToken      = status.Errorf(codes.Unauthenticated, "reason: %v", v1.ErrorReason_INVALID_TOKEN.String())
)
View Source
var ProviderSet = wire.NewSet(NewAuthUsecase)

ProviderSet is biz providers.

Functions

This section is empty.

Types

type AuthUsecase

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

AuthUsecase is an Auth usecase.

func NewAuthUsecase

func NewAuthUsecase(repo UserRepo, logger log.Logger, hasher hash.PasswordHasher, tokenMaker paseto.TokenMaker) *AuthUsecase

NewAuthUsecase new an Auth usecase.

func (*AuthUsecase) ComparePassword

func (uc *AuthUsecase) ComparePassword(ctx context.Context, email, pass string) (*User, error)

ComparePassword compare pass with the one saved in db

func (*AuthUsecase) CreateUser

func (uc *AuthUsecase) CreateUser(ctx context.Context, u *User) (*User, error)

CreateUser save new user to db

func (*AuthUsecase) GetIdFromRefresh

func (uc *AuthUsecase) GetIdFromRefresh(ctx context.Context, refresh string) (int64, error)

GetIdFromRefresh parse refresh token & return user id

func (*AuthUsecase) Identity

func (uc *AuthUsecase) Identity(ctx context.Context, access string) (int64, error)

Identity identifies user

func (*AuthUsecase) NewTokens

func (uc *AuthUsecase) NewTokens(ctx context.Context, userId int64) (*v1.Tokens, error)

NewTokens generate new access & refresh paseto tokens

type User

type User struct {
	ID       int64
	Name     string
	Email    string
	Password string
}

User is a user model.

type UserRepo

type UserRepo interface {
	Save(context.Context, *User) (*User, error)
	FindByEmail(context.Context, string) (*User, error)
}

UserRepo is a User repo.

Jump to

Keyboard shortcuts

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