services

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeEmailVerification = "email_verification"
	ScopeUnsubscribe       = "unsubscribe"
	ScopeResetPassword     = "password_reset"
)

Variables

View Source
var (
	ErrInvalidInput         = errors.New("one or more of the provided inputs are not valid")
	ErrEmailNotValidated    = errors.New("user email not validated")
	ErrUserNotExist         = errors.New("user have not been registered")
	ErrPasswordNotMatch     = errors.New("provided password does not match our records")
	ErrPasswordMatchConfirm = errors.New("provided password does not match confirm password")
	ErrPasswordLength       = errors.New("provided password has insufficient length")
	ErrTokenNotExist        = errors.New("the provided token does not exist")
	ErrTokenExpired         = errors.New("token expired")
	ErrTokenScopeInvalid    = errors.New("the scope of the token was not what was expected")
	ErrUnrecoverable        = errors.New("an unexpected error has occurred")
)

Functions

This section is empty.

Types

type Auth

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

func NewAuth

func NewAuth(
	db psql.Postgres,
	email emailClient.EmailClient,
) Auth

func (Auth) AuthenticateUser

func (a Auth) AuthenticateUser(
	ctx context.Context,
	email string,
	password string,
) error

func (Auth) RegisterUser

func (a Auth) RegisterUser(
	ctx context.Context,
	name string,
	email string,
	password string,
	confirmPassword string,
) error

func (Auth) VerifyUserEmail

func (a Auth) VerifyUserEmail(
	ctx context.Context,
	token string,
	scope string,
) error

type Token

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

func NewTokenSvc

func NewTokenSvc(
	db psql.Postgres,
	tokenSigningKey string,
) *Token

func (*Token) CreateResetPasswordToken

func (svc *Token) CreateResetPasswordToken(
	ctx context.Context,
	userID uuid.UUID,
) (string, error)

func (*Token) CreateSubscriberEmailValidation

func (svc *Token) CreateSubscriberEmailValidation(
	ctx context.Context,
	subscriberID uuid.UUID,
) (string, error)

func (*Token) CreateUnsubscribeToken

func (svc *Token) CreateUnsubscribeToken(
	ctx context.Context,
	subscriberID uuid.UUID,
) (string, error)

func (*Token) CreateUserEmailVerification

func (svc *Token) CreateUserEmailVerification(
	ctx context.Context,
	userID uuid.UUID,
) (string, error)

func (*Token) Delete

func (svc *Token) Delete(ctx context.Context, token string) error

func (*Token) GetAssociatedSubscriberID

func (svc *Token) GetAssociatedSubscriberID(
	ctx context.Context,
	token string,
) (uuid.UUID, error)

func (*Token) GetAssociatedUserID

func (svc *Token) GetAssociatedUserID(ctx context.Context, token string) (uuid.UUID, error)

func (*Token) IsExpired

func (svc *Token) IsExpired(ctx context.Context, token string) error

func (*Token) Validate

func (svc *Token) Validate(ctx context.Context, token, scope string) error

type TokenMetaInformation

type TokenMetaInformation struct {
	Resource   string    `json:"resource"`
	ResourceID uuid.UUID `json:"resource_id"`
	Scope      string    `json:"scope"`
}

Jump to

Keyboard shortcuts

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