set format base64 for sign in email sender

This commit is contained in:
Pavel 2024-01-03 19:19:27 +03:00
parent 922222d2c8
commit cfc90597cc
2 changed files with 6 additions and 6 deletions

@ -2,6 +2,7 @@ package client
import (
"bytes"
"encoding/base64"
"fmt"
"github.com/gofiber/fiber/v2"
"go.uber.org/zap"
@ -34,15 +35,12 @@ func NewRecoveryEmailSender(deps RecoveryEmailSenderDeps) *RecoveryEmailSender {
}
func (r *RecoveryEmailSender) SendRecoveryEmail(email string, signature []byte) error {
signatureStr := base64.URLEncoding.EncodeToString(signature)
url := r.deps.SmtpApiUrl
fmt.Println(email, signature)
fmt.Println(email, signatureStr)
message := fmt.Sprintf("To: %s\r\n"+
"Subject: Восстановление доступа\r\n"+
"\r\n"+
"Чтобы восстановить доступ, пожалуйста, перейдите по ссылке ниже:\r\n"+
" https://hub.pena.digital/codeword/restore/%s\r\n", email, signature)
message := fmt.Sprintf("https://hub.pena.digital/codeword/restore/%s", signatureStr)
form := new(bytes.Buffer)
writer := multipart.NewWriter(form)

@ -5,6 +5,7 @@ import (
"codeword/internal/models"
"context"
"encoding/json"
"fmt"
"github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
@ -79,6 +80,7 @@ func (wc *recoveryWorker) processTasks(ctx context.Context) {
}
func (wc *recoveryWorker) sendRecoveryTask(ctx context.Context, task models.RecoveryRecord) error {
fmt.Println("task.Key", task.Key)
err := wc.emailSender.SendRecoveryEmail(task.Email, task.Key)
if err != nil {
wc.logger.Error("Failed to send recovery email", zap.Error(err))