MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / SendCode

Method SendCode

internal/repository/email.go:32–46  ·  view source on GitHub ↗
(ctx context.Context, email string)

Source from the content-addressed store, hash-verified

30}
31
32func (e emailRepository) SendCode(ctx context.Context, email string) error {
33 e.l.Info("[emailRepository.SendCode]", zap.String("email", email))
34 vCode := utils.GenRandomCode(6)
35 e.l.Info("[emailRepository.SendCode]", zap.String("vCode", vCode))
36 if err := e.cache.StoreVCode(ctx, email, vCode); err != nil {
37 e.l.Error("[emailRepository.SendCode] StoreVCode失败", zap.Error(err))
38 return err
39 }
40 body := fmt.Sprintf("您的验证码是:%s", vCode)
41 if viper.GetString("email.provider") != "qq" {
42 e.l.Info("[emailRepository.SendCode] 邮件验证码走模拟通道", zap.String("email", email), zap.String("vCode", vCode))
43 return nil
44 }
45 return qqEmail.SendEmail(email, "【LinkMe】密码重置", body)
46}
47
48func (e emailRepository) CheckCode(ctx context.Context, email, vCode string) (bool, error) {
49 storedCode, err := e.cache.GetVCode(ctx, email)

Callers

nothing calls this directly

Calls 3

GenRandomCodeFunction · 0.92
SendEmailMethod · 0.80
StoreVCodeMethod · 0.65

Tested by

no test coverage detected