auth

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CleanUpExpiredVerificationRequestsTask = "clean_up_expired_verification_requests"
	CleanUpExpiredTokensTask               = "clean_up_expired_tokens"
)

Variables

View Source
var (
	ErrEmailTaken                 = errors.New("Email is already taken")
	ErrInvalidCredentials         = errors.New("Invalid credentials. Please check your email and password and try again.")
	ErrUserNotFound               = errors.New("User not found")
	ErrInvalidVerificationRequest = errors.New("Invalid verification request")
	ErrInvalidVerificationCode    = errors.New("Invalid verification code")
	ErrVerificationCodeExpired    = errors.New("Verification code expired")
	ErrUserNotVerified            = errors.New("User not verified")
	ErrUserAlreadyVerified        = errors.New("User already verified")
)

Predefined errors

Functions

func MakeHTTPHandler

func MakeHTTPHandler(srv Service, oauth2AuthURI string, notAuthMdw httpMiddleware) http.Handler

MakeHTTPHandler returns a handler that makes a set of endpoints available on predefined paths.

Types

type Service

type Service interface {
	// Login authenticates a user and returns a user ID.
	Login(ctx context.Context, email, password string) (uuid.UUID, error)
	// Register creates a new user and returns a user ID.
	Register(ctx context.Context, email, password string) (uuid.UUID, error)
	// PasswordRecovery sends a password recovery email.
	PasswordRecovery(ctx context.Context, email string) error
	// PasswordReset resets a user password.
	PasswordReset(ctx context.Context, email, otp, password string) error
	// Verify user email with otp code
	VerifyEmail(ctx context.Context, email, code string) error
	// Resend verification email
	ResendVerificationEmail(ctx context.Context, email string) error
	// DestroyProfileRequest sends a destroy profile email.
	DestroyProfileRequest(ctx context.Context, email string) error
	// DestroyProfile destroys a user profile.
	DestroyProfile(ctx context.Context, email, otp string) error
}

func NewService

func NewService(repo authRepository, db *sql.DB, m mailer) Service

NewService creates a new auth service.

type Worker

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

Worker is a task handler for email delivery.

func NewWorker

func NewWorker(repo workerRepository) *Worker

NewWorker creates a new email task handler.

func (*Worker) CleanUpExpiredTokens

func (w *Worker) CleanUpExpiredTokens(ctx context.Context, t *asynq.Task) error

CleanUpExpiredTokens cleans up expired tokens.

func (*Worker) CleanUpExpiredVerificationRequests

func (w *Worker) CleanUpExpiredVerificationRequests(ctx context.Context, t *asynq.Task) error

CleanUpExpiredVerificationRequests cleans up expired verification requests.

func (*Worker) Register

func (w *Worker) Register(mux *asynq.ServeMux)

Register registers task handlers for email delivery.

func (*Worker) Schedule

func (w *Worker) Schedule(s *asynq.Scheduler)

Schedule schedules tasks for the worker.

Jump to

Keyboard shortcuts

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