(ctx context.Context, email string)
| 30 | } |
| 31 | |
| 32 | func (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 | |
| 48 | func (e emailRepository) CheckCode(ctx context.Context, email, vCode string) (bool, error) { |
| 49 | storedCode, err := e.cache.GetVCode(ctx, email) |
nothing calls this directly
no test coverage detected