application

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithMessageProducer

func WithMessageProducer(mp MessageProducer) func(*UseCases)

func WithPasswordHasher

func WithPasswordHasher(h PasswordHasher) func(*UseCases)

func WithSessionRepository

func WithSessionRepository(sr SessionRepository) func(*UseCases)

func WithTokenGenerator

func WithTokenGenerator(tg TokenGenerator) func(*UseCases)

func WithTokenRepository

func WithTokenRepository(tr TokenRepository) func(*UseCases)

func WithUserRepository

func WithUserRepository(ur UserRepository) func(*UseCases)

func WithValidator

func WithValidator(v Validator) func(*UseCases)

Types

type Command

type Command struct {
	Signin     SigninCommand
	Signup     SignupCommand
	Logout     LogoutCommand
	RenewToken RenewTokenCommand
}

type GetUserDevicesCommand

type GetUserDevicesCommand interface {
	Execute(ctx context.Context, params GetUserDevicesParams) ([]core.Session, error)
}

GetUserDevicesCommand is the interface for the GetUserDevicesCommandImpl

func NewGetUserDevicesCommand

func NewGetUserDevicesCommand(
	v Validator,
	sr SessionRepository,
) GetUserDevicesCommand

NewGetUserDevicesCommand returns a new GetUserDevicesCommand with the passed dependencies

type GetUserDevicesCommandImpl

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

GetUserDevicesCommandImpl is the implementation of the GetUserDevicesCommand

func (*GetUserDevicesCommandImpl) Execute

Execute executes the GetUserDevicesCommand with the given parameters

type GetUserDevicesParams

type GetUserDevicesParams struct{}

GetUserDevicesParams contains the parameters for the GetUserDevicesCommand

type LogoutCommand

type LogoutCommand interface {
	Execute(ctx context.Context, params LogoutParams) error
}

type LogoutCommandImpl

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

func (*LogoutCommandImpl) Execute

func (c *LogoutCommandImpl) Execute(ctx context.Context, params LogoutParams) error

type LogoutParams

type LogoutParams struct {
	SessionID string `validate:"required,uuid"`
}

type MessageProducer

type MessageProducer interface {
	SendNewSignInSessionMessage(ctx context.Context, params core.SendNewSignInSessionParams) error
}

MessageProducer is an interface for sending messages to a queue

type PasswordHasher

type PasswordHasher interface {
	Hash(ctx context.Context, password string) (hashedPassword string, err error)
	Compare(ctx context.Context, password, hash string) (isSamePassword bool)
}

PasswordHasher is an interface for hashing and comparing passwords

type Query

type Query struct {
	GetUserDevices GetUserDevicesCommand
}

type RenewTokenCommand

type RenewTokenCommand interface {
	Execute(ctx context.Context, params RenewTokenParams) (*RenewTokenResponse, error)
}

RenewTokenCommand is the interface for the RenewTokenCommand

func NewRenewTokenCommand

NewRenewTokenCommand creates a new RenewTokenCommand with the passed dependencies

type RenewTokenCommandImpl

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

RenewTokenCommandImpl is the implementation of the RenewTokenCommand

func (*RenewTokenCommandImpl) Execute

Execute executes the RenewTokenCommand with the given params

type RenewTokenParams

type RenewTokenParams struct {
	RefreshToken string `validate:"required"`
}

RenewTokenParams is the input for the RenewTokenCommand

type RenewTokenResponse

type RenewTokenResponse struct {
	AccessToken  string
	RefreshToken string
}

RenewTokenResponse is the output for the RenewTokenCommand

type SessionRepository

type SessionRepository interface {
	CreateSession(ctx context.Context, arg core.CreateSessionParams) error
	GetSessionByID(ctx context.Context, id uuid.UUID) (core.Session, error)
	GetUserSessions(ctx context.Context, userID uuid.UUID) ([]core.Session, error)
	UpdateSessionTokens(ctx context.Context, params core.UpdateSessionTokenParams) error
	DeleteSessionByID(ctx context.Context, sessionID uuid.UUID) error
}

SessionRepository is an interface for interacting with sessions in the database

type SigninCommand

type SigninCommand interface {
	Execute(ctx context.Context, params SigninParams) (SigninResponse, error)
}

SigninCommand is the interface for the SigninCommandImpl

func NewSigninCommand

NewSigninCommand returns a new SigninCommand with the passed dependencies

type SigninCommandImpl

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

SigninCommandImpl is the implementation of the SigninCommand

func (*SigninCommandImpl) Execute

Execute executes the SigninCommand with the given parameters

type SigninParams

type SigninParams struct {
	Email     string `validate:"required,email"`
	Password  string `validate:"required,min=8"`
	ClientIP  string `validate:"required,ip"`
	UserAgent string `validate:"required,min=1"`
}

SigninParams contains the parameters for the SigninCommand

type SigninResponse

type SigninResponse struct {
	AccessToken  string
	RefreshToken string
}

SigninResponse contains the response for the SigninCommand

type SignupCommand

type SignupCommand interface {
	Execute(ctx context.Context, params SignupParams) error
}

type SignupCommandImpl

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

func (*SignupCommandImpl) Execute

func (c *SignupCommandImpl) Execute(ctx context.Context, params SignupParams) error

type SignupParams

type SignupParams struct {
	FirstName string `validate:"required,alpha"`
	LastName  string `validate:"required,alpha"`
	Username  string `validate:"required,alphanum"`
	Email     string `validate:"required,email"`
	Password  string `validate:"required,min=8"`
}

type TokenGenerator

type TokenGenerator interface {
	GenerateAccessToken(ctx context.Context, params core.GenerateTokenParam) (token string, err error)
	GenerateRefreshToken(ctx context.Context, params core.GenerateTokenParam) (token string, err error)
	DecryptToken(ctx context.Context, token string) (params core.TokenPayload, err error)
}

TokenGenerator is an interface for generating and verifying tokens

type TokenRepository

type TokenRepository interface {
	Store(ctx context.Context, token string, params core.TokenPayload) error
	Delete(ctx context.Context, token string) error
}

TokenRepository is an interface for interacting with tokens in cache

type UseCases

type UseCases struct {
	Query
	Command
	// contains filtered or unexported fields
}

func NewUseCases

func NewUseCases(opts ...func(*UseCases)) *UseCases

type UserRepository

type UserRepository interface {
	CreateUser(ctx context.Context, arg core.CreateUserParams) error
	GetUserByID(ctx context.Context, id uuid.UUID) (core.User, error)
	GetUserByEmail(ctx context.Context, email string) (core.User, error)
}

UserRepository is an interface for interacting with users in the database

type Validator

type Validator interface {
	Validate(ctx context.Context, s interface{}) (err error)
}

Validator is an interface for validating structs using tags

Jump to

Keyboard shortcuts

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