Documentation
¶
Index ¶
- func WithMessageProducer(mp MessageProducer) func(*UseCases)
- func WithPasswordHasher(h PasswordHasher) func(*UseCases)
- func WithSessionRepository(sr SessionRepository) func(*UseCases)
- func WithTokenGenerator(tg TokenGenerator) func(*UseCases)
- func WithTokenRepository(tr TokenRepository) func(*UseCases)
- func WithUserRepository(ur UserRepository) func(*UseCases)
- func WithValidator(v Validator) func(*UseCases)
- type Command
- type GetUserDevicesCommand
- type GetUserDevicesCommandImpl
- type GetUserDevicesParams
- type LogoutCommand
- type LogoutCommandImpl
- type LogoutParams
- type MessageProducer
- type PasswordHasher
- type Query
- type RenewTokenCommand
- type RenewTokenCommandImpl
- type RenewTokenParams
- type RenewTokenResponse
- type SessionRepository
- type SigninCommand
- type SigninCommandImpl
- type SigninParams
- type SigninResponse
- type SignupCommand
- type SignupCommandImpl
- type SignupParams
- type TokenGenerator
- type TokenRepository
- type UseCases
- type UserRepository
- type Validator
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 ¶
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 ¶
func (c *GetUserDevicesCommandImpl) Execute(ctx context.Context, params GetUserDevicesParams) ([]core.Session, error)
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
}
func NewLogoutCommand ¶
func NewLogoutCommand(v Validator, sr SessionRepository, tr TokenRepository) LogoutCommand
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 ¶
func NewRenewTokenCommand(v Validator, tg TokenGenerator, sr SessionRepository, tr TokenRepository) RenewTokenCommand
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 ¶
func (c *RenewTokenCommandImpl) Execute(ctx context.Context, params RenewTokenParams) (*RenewTokenResponse, error)
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 ¶
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 ¶
func NewSigninCommand( v Validator, h PasswordHasher, tg TokenGenerator, ur UserRepository, sr SessionRepository, tr TokenRepository, mp MessageProducer, ) SigninCommand
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 ¶
func (c *SigninCommandImpl) Execute(ctx context.Context, params SigninParams) (SigninResponse, error)
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 ¶
SigninResponse contains the response for the SigninCommand
type SignupCommand ¶
type SignupCommand interface {
Execute(ctx context.Context, params SignupParams) error
}
func NewSignupCommand ¶
func NewSignupCommand(v Validator, h PasswordHasher, ur UserRepository) SignupCommand
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 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 ¶
func NewUseCases ¶
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