🐛 登录问题
This commit is contained in:
@@ -83,18 +83,16 @@ func (s *UserLoginServiceV1) Register(ctx context.Context, req *v1.UserRegisterR
|
||||
})
|
||||
|
||||
// 注册成功后发送欢迎邮件(异步发送,不影响注册结果)
|
||||
go func() {
|
||||
token := make([]byte, 32)
|
||||
_, _ = rand.Read(token)
|
||||
tokenStr := base64.URLEncoding.EncodeToString(token)
|
||||
set := redis.GetClient().Set(ctx, cst.RedisVerifyCode+tokenStr, req.Email, time.Duration(cst.RedisVerifyCodeExpire)*time.Second)
|
||||
err2 := set.Err()
|
||||
utils.OkOrPanic(err2)
|
||||
// 创建新的context避免原context被取消
|
||||
emailCtx := context.Background()
|
||||
emailService := email.NewV1()
|
||||
emailService.SendSignupEmail(emailCtx, req.Email, req.Username, tokenStr)
|
||||
}()
|
||||
// 异步无法获取报错信息,改为同步
|
||||
token := make([]byte, 32)
|
||||
_, _ = rand.Read(token)
|
||||
tokenStr := base64.URLEncoding.EncodeToString(token)
|
||||
err2 := redis.GetClient().SetEx(ctx, cst.RedisVerifyCode+tokenStr, req.Email, time.Duration(cst.RedisVerifyCodeExpire)*time.Second).Err()
|
||||
utils.OkOrPanic(err2, oops.WithContext(ctx).Wrap)
|
||||
// 创建新的context避免原context被取消
|
||||
emailCtx := context.Background()
|
||||
emailService := email.NewV1()
|
||||
emailService.SendSignupEmail(emailCtx, req.Email, req.Username, tokenStr)
|
||||
|
||||
return utils.SuccessWithMsg("注册成功")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user