change fetch users

This commit is contained in:
Pavel 2024-01-18 18:35:20 +03:00
parent a8aae6ded4
commit c032d3f591
2 changed files with 26 additions and 20 deletions

4
.env

@ -18,9 +18,13 @@ REDIS_DB=2
# Keys # Keys
PUBLIC_CURVE_KEY="-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAEbnIvjIMle4rqVol6K2XUqOxHy1KJoNoZdKJrRUPKL4=\n-----END PUBLIC KEY-----" PUBLIC_CURVE_KEY="-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAEbnIvjIMle4rqVol6K2XUqOxHy1KJoNoZdKJrRUPKL4=\n-----END PUBLIC KEY-----"
PRIVATE_CURVE_KEY="-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIKn0BKwF3vZvODgWAnUIwQhd8de5oZhY48gc23EWfrfs\n-----END PRIVATE KEY-----" PRIVATE_CURVE_KEY="-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIKn0BKwF3vZvODgWAnUIwQhd8de5oZhY48gc23EWfrfs\n-----END PRIVATE KEY-----"
SIGN_SECRET="pena-auth-microservice-group" SIGN_SECRET="pena-auth-microservice-group"
SIGN_SECRET="secret"
# SMTP settings # SMTP settings
SMTP_API_URL="https://api.smtp.bz/v1/smtp/send" SMTP_API_URL="https://api.smtp.bz/v1/smtp/send"
SMTP_HOST="connect.mailclient.bz" SMTP_HOST="connect.mailclient.bz"

@ -1,7 +1,9 @@
package controller package controller
import ( import (
"codeword/internal/models"
"codeword/internal/services" "codeword/internal/services"
"encoding/base64"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"go.uber.org/zap" "go.uber.org/zap"
"time" "time"
@ -42,32 +44,32 @@ func (r *RecoveryController) HandleRecoveryRequest(c *fiber.Ctx) error {
r.logger.Error("Failed to find user by email", zap.Error(err)) r.logger.Error("Failed to find user by email", zap.Error(err))
return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"error": "User not found"}) return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"error": "User not found"})
} }
key := "GSiyv5zBITGshqnvYLHKtXE3e4yZjKGvruOVFWuUuj9Nvaps28-Zt6RDq9n47eaNUlay1-nUVld61I3xoAAgCA==65a79d5d67734ab00b3c9463"
//key, err := r.service.GenerateKey()
//if err != nil {
// r.logger.Error("Failed to generate key", zap.Error(err))
// return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Internal Server Error"})
//}
//signUrl := redirectionURL + key key, err := r.service.GenerateKey()
//sign := key if err != nil {
r.logger.Error("Failed to generate key", zap.Error(err))
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Internal Server Error"})
}
//id, err := r.service.StoreRecoveryRecord(c.Context(), models.StoreRecDeps{UserID: user.ID.Hex(), Email: user.Email, Key: sign, Url: signUrl}) signUrl := redirectionURL + base64.URLEncoding.EncodeToString(key)
//if err != nil { sign := base64.URLEncoding.EncodeToString(key)
// r.logger.Error("Failed to store recovery record", zap.Error(err))
// return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Internal Server Error"})
//}
//signWithID := sign + id // подпись с id записи id, err := r.service.StoreRecoveryRecord(c.Context(), models.StoreRecDeps{UserID: user.ID.Hex(), Email: user.Email, Key: sign, Url: signUrl})
if err != nil {
r.logger.Error("Failed to store recovery record", zap.Error(err))
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Internal Server Error"})
}
//err = r.service.RecoveryEmailTask(c.Context(), models.RecEmailDeps{UserID: user.ID.Hex(), Email: email, SignWithID: signWithID, ID: id}) signWithID := sign + id // подпись с id записи
//if err != nil {
// r.logger.Error("Failed to send recovery email", zap.Error(err)) err = r.service.RecoveryEmailTask(c.Context(), models.RecEmailDeps{UserID: user.ID.Hex(), Email: email, SignWithID: signWithID, ID: id})
// return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Internal Server Error"}) if err != nil {
//} r.logger.Error("Failed to send recovery email", zap.Error(err))
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Internal Server Error"})
}
return c.Status(fiber.StatusOK).JSON(fiber.Map{ return c.Status(fiber.StatusOK).JSON(fiber.Map{
"id": key, "id": id,
}) })
} }