set format base64 for sign in email sender
This commit is contained in:
parent
922222d2c8
commit
cfc90597cc
@ -2,6 +2,7 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@ -34,15 +35,12 @@ func NewRecoveryEmailSender(deps RecoveryEmailSenderDeps) *RecoveryEmailSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RecoveryEmailSender) SendRecoveryEmail(email string, signature []byte) error {
|
func (r *RecoveryEmailSender) SendRecoveryEmail(email string, signature []byte) error {
|
||||||
|
signatureStr := base64.URLEncoding.EncodeToString(signature)
|
||||||
url := r.deps.SmtpApiUrl
|
url := r.deps.SmtpApiUrl
|
||||||
|
|
||||||
fmt.Println(email, signature)
|
fmt.Println(email, signatureStr)
|
||||||
|
|
||||||
message := fmt.Sprintf("To: %s\r\n"+
|
message := fmt.Sprintf("https://hub.pena.digital/codeword/restore/%s", signatureStr)
|
||||||
"Subject: Восстановление доступа\r\n"+
|
|
||||||
"\r\n"+
|
|
||||||
"Чтобы восстановить доступ, пожалуйста, перейдите по ссылке ниже:\r\n"+
|
|
||||||
" https://hub.pena.digital/codeword/restore/%s\r\n", email, signature)
|
|
||||||
|
|
||||||
form := new(bytes.Buffer)
|
form := new(bytes.Buffer)
|
||||||
writer := multipart.NewWriter(form)
|
writer := multipart.NewWriter(form)
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"codeword/internal/models"
|
"codeword/internal/models"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"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 {
|
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)
|
err := wc.emailSender.SendRecoveryEmail(task.Email, task.Key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wc.logger.Error("Failed to send recovery email", zap.Error(err))
|
wc.logger.Error("Failed to send recovery email", zap.Error(err))
|
||||||
|
Loading…
Reference in New Issue
Block a user