auth

package
v0.0.0-...-f15602e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package auth contains authorization oriented logic.

Package auth is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoginProps

type LoginProps struct {
	Email    string
	Password string
}

LoginProps represents login props.

type MockService

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

MockService is a mock of Service interface.

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance.

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockService) Login

func (m *MockService) Login(ctx context.Context, props *LoginProps) (string, error)

Login mocks base method.

func (*MockService) SignToken

func (m *MockService) SignToken(usr *user.User) (string, error)

SignToken mocks base method.

func (*MockService) Signup

func (m *MockService) Signup(ctx context.Context, props *SignupProps) (string, error)

Signup mocks base method.

func (*MockService) ValidateToken

func (m *MockService) ValidateToken(accessToken string) (*UserClaims, error)

ValidateToken mocks base method.

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) Login

func (mr *MockServiceMockRecorder) Login(ctx, props any) *gomock.Call

Login indicates an expected call of Login.

func (*MockServiceMockRecorder) SignToken

func (mr *MockServiceMockRecorder) SignToken(usr any) *gomock.Call

SignToken indicates an expected call of SignToken.

func (*MockServiceMockRecorder) Signup

func (mr *MockServiceMockRecorder) Signup(ctx, props any) *gomock.Call

Signup indicates an expected call of Signup.

func (*MockServiceMockRecorder) ValidateToken

func (mr *MockServiceMockRecorder) ValidateToken(accessToken any) *gomock.Call

ValidateToken indicates an expected call of ValidateToken.

type Service

type Service interface {
	Login(ctx context.Context, props *LoginProps) (string, error)
	Signup(ctx context.Context, props *SignupProps) (string, error)
	SignToken(usr *user.User) (string, error)
	ValidateToken(accessToken string) (*UserClaims, error)
}

Service represents auth use cases.

type SignupProps

type SignupProps struct {
	Email    string
	Name     string
	Phone    string
	Password string
}

SignupProps represents signup props.

type UseCase

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

UseCase represents auth service.

func NewUseCase

func NewUseCase(logger *zap.Logger, conf *config.AuthConfig, userRepo user.Repository) *UseCase

NewUseCase create instance of UseCase.

func (UseCase) Login

func (s UseCase) Login(ctx context.Context, props *LoginProps) (string, error)

Login user.

func (UseCase) SignToken

func (s UseCase) SignToken(usr *user.User) (string, error)

SignToken sign authorization token.

func (UseCase) Signup

func (s UseCase) Signup(ctx context.Context, props *SignupProps) (string, error)

Signup user.

func (UseCase) ValidateToken

func (s UseCase) ValidateToken(accessToken string) (*UserClaims, error)

ValidateToken check and parse authorization token.

type UserClaims

type UserClaims struct {
	jwt.RegisteredClaims
	UserID   user.ID   `json:"userId"`
	UserRole user.Role `json:"userRole"`
}

UserClaims represents jwt claims.

Jump to

Keyboard shortcuts

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