bookclub

package module
v0.0.0-...-394bd34 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: MIT Imports: 7 Imported by: 0

README

bookclub

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPasswordMismatch   error = errors.New("password mismatch")
	ErrInvalidPassword          = errors.New("password must be between 8 and 30 characters and contain at least one number, one uppercase letter, one lowercase letter, and one special character")
	ErrInvalidEmail       error = errors.New("invalid email")
	ErrInternalError      error = errors.New("internal error")
	ErrAlreadyExists            = errors.New("resource already exists")
	ErrInvalidCredentials       = errors.New("invalid credentials")
	ErrNotFound                 = errors.New("resource not found")
	ErrInvalidBody              = errors.New("invalid request body")
)

Functions

This section is empty.

Types

type AuthUseCases

type AuthUseCases interface {
	Login(ctx context.Context, params LoginParams) (string, string, error)
	Refresh(ctx context.Context, refreshToken string) (string, string, error)
}

type Email

type Email string

func NewEmail

func NewEmail(value string) (Email, error)

type JWTClaims

type JWTClaims struct {
	Subject   string
	Refresh   bool
	IssuedAt  time.Time
	ExpiresAt time.Time
}

type JWTGenerateParams

type JWTGenerateParams struct {
	UserID  string
	TTL     time.Duration
	Refresh bool
}

type JWTProvider

type JWTProvider interface {
	GenerateToken(ctx context.Context, params JWTGenerateParams) (string, error)
	GenerateRefreshToken(ctx context.Context, params JWTGenerateParams) (string, error)
	ValidateToken(ctx context.Context, token string) (JWTClaims, error)
}

type LoginParams

type LoginParams struct {
	Email    string
	Password string
}

type Password

type Password []byte

func NewPassword

func NewPassword(password string) (Password, error)

func (Password) Compare

func (o Password) Compare(password string, hashedPassword Password) error

type RegisterParams

type RegisterParams struct {
	Email    string
	Password string
}

type Storage

type Storage interface {
	CreateUser(ctx context.Context, email Email, passwd Password) (User, error)
	GetUserByEmail(ctx context.Context, email Email) (User, error)
}

type User

type User struct {
	ID    uuid.UUID
	Email Email

	CreatedAt time.Time
	UpdatedAt time.Time
	// contains filtered or unexported fields
}

func (*User) ComparePassword

func (o *User) ComparePassword(password string) error

func (*User) SetPassword

func (o *User) SetPassword(password Password)

type UserUseCases

type UserUseCases interface {
	Register(ctx context.Context, params RegisterParams) (User, error)
}

Directories

Path Synopsis
api
schema
Package schema provides primitives to interact with the openapi HTTP API.
Package schema provides primitives to interact with the openapi HTTP API.
cmd
rest-api command
Code generated by MockGen.
Code generated by MockGen.
db
usecases

Jump to

Keyboard shortcuts

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