update user change email

This commit is contained in:
aichy126 2022-10-31 16:50:38 +08:00
parent beed798aa6
commit 302150aa6e
1 changed files with 9 additions and 4 deletions

View File

@ -492,7 +492,7 @@ func (us *UserService) encryptPassword(ctx context.Context, Pass string) (string
// UserChangeEmailSendCode user change email verification
func (us *UserService) UserChangeEmailSendCode(ctx context.Context, req *schema.UserChangeEmailSendCodeReq) error {
_, exist, err := us.userRepo.GetByUserID(ctx, req.UserID)
userInfo, exist, err := us.userRepo.GetByUserID(ctx, req.UserID)
if err != nil {
return err
}
@ -513,10 +513,15 @@ func (us *UserService) UserChangeEmailSendCode(ctx context.Context, req *schema.
UserID: req.UserID,
}
code := uuid.NewString()
var title, body string
verifyEmailUrl := fmt.Sprintf("%s/users/confirm-new-email?code=%s", us.serviceConfig.WebHost, code)
title, body, err := us.emailService.ChangeEmailTemplate(ctx, verifyEmailUrl)
if err != nil {
return err
if userInfo.MailStatus == entity.EmailStatusToBeVerified {
title, body, err = us.emailService.RegisterTemplate(ctx, verifyEmailUrl)
} else {
title, body, err = us.emailService.ChangeEmailTemplate(ctx, verifyEmailUrl)
if err != nil {
return err
}
}
log.Infof("send email confirmation %s", verifyEmailUrl)