handler

package
v0.0.0-...-65546df Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler struct {
	Token          *token.Resolver
	UserRepo       repo.UserRepo
	CaptchaHandler CaptchaHandler
}

AuthHandler is responsible for user authentication

func (AuthHandler) EncryptPassword

func (a AuthHandler) EncryptPassword(s string) string

EncryptPassword encrypts password with sha512

func (AuthHandler) LoginWithPassword

func (a AuthHandler) LoginWithPassword(ctx context.Context, option types.LoginOptions) (token.Pair, error)

LoginWithPassword user login by password

func (AuthHandler) RegisterNewUser

func (a AuthHandler) RegisterNewUser(ctx context.Context, option types.RegisterOptions) (*ent.User, error)

RegisterNewUser registers new user and returns it

func (AuthHandler) ResetPassword

func (a AuthHandler) ResetPassword(ctx context.Context, option types.ResetOptions) error

ResetPassword resets specified user password and returns uid

type CaptchaHandler

type CaptchaHandler struct {
	CaptchaCache cache.CaptchaCache
	EmailHandler EmailHandler

	MetaInfo conf.MetaInfo
}

func (CaptchaHandler) Check

func (v CaptchaHandler) Check(ctx context.Context, to, code string, usage types.Usage) error

Check checks captcha if is valid

func (CaptchaHandler) Remove

func (v CaptchaHandler) Remove(ctx context.Context, code string, usage types.Usage) error

Remove removes captcha from cache

func (CaptchaHandler) SendCaptchaEmail

func (v CaptchaHandler) SendCaptchaEmail(ctx context.Context, to string, usage types.Usage) error

SendCaptchaEmail send a verify code email to the specified address

type EmailConsumer

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

EmailConsumer is responsible for reading messages from Queue and then send these emails.

func (*EmailConsumer) Consume

func (c *EmailConsumer) Consume(ctx context.Context, id string, value any) error

func (*EmailConsumer) Group

func (c *EmailConsumer) Group() string

func (*EmailConsumer) Name

func (c *EmailConsumer) Name() string

func (*EmailConsumer) Size

func (c *EmailConsumer) Size() int64

func (*EmailConsumer) Topic

func (c *EmailConsumer) Topic() string

type EmailHandler

type EmailHandler struct {
	Config conf.Email
	Sender *email.Sender

	Queue mq.Queue
}

EmailHandler is responsible for publishing and sending emails

func NewEmailHandler

func NewEmailHandler(cfg conf.Email, sender *email.Sender, queue mq.Queue) (EmailHandler, error)

func (*EmailHandler) Publish

func (e *EmailHandler) Publish(ctx context.Context, msg email.Message) error

Publish publishes message to Queue

type HealthHandler

type HealthHandler struct {
}

type UserHandler

type UserHandler struct {
	UserRepo *repo.UserRepo
}

func (UserHandler) CreateUser

func (u UserHandler) CreateUser(ctx context.Context, username string, email string, password string) (types2.UserInfo, error)

func (UserHandler) FindByUID

func (u UserHandler) FindByUID(ctx context.Context, uid string) (types2.UserInfo, error)

func (UserHandler) ListUserByPage

func (u UserHandler) ListUserByPage(ctx context.Context, page, size int, pattern string) (types2.UserSearchResult, error)

func (UserHandler) RemoveUser

func (u UserHandler) RemoveUser(ctx context.Context, uid string) error

Jump to

Keyboard shortcuts

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