add rec url to env
This commit is contained in:
parent
24ba370ccd
commit
e7e249a2ba
1
.env
1
.env
@ -38,6 +38,7 @@ SMTP_SENDER="noreply@mailing.pena.digital"
|
|||||||
DEFAULT_REDIRECTION_URL = "def.url"
|
DEFAULT_REDIRECTION_URL = "def.url"
|
||||||
AUTH_EXCHANGE_URL = "http://localhost:8000/auth/exchange"
|
AUTH_EXCHANGE_URL = "http://localhost:8000/auth/exchange"
|
||||||
DISCOUNT_ADDRESS = "http://CHANGEME:1234"
|
DISCOUNT_ADDRESS = "http://CHANGEME:1234"
|
||||||
|
RECOVERY_URL = "http://127.0.0.1:8080/recover/"
|
||||||
|
|
||||||
# Kafka settings
|
# Kafka settings
|
||||||
KAFKA_BROKERS="localhost:9092"
|
KAFKA_BROKERS="localhost:9092"
|
||||||
|
@ -9,17 +9,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type RecoveryEmailSenderDeps struct {
|
type RecoveryEmailSenderDeps struct {
|
||||||
SmtpApiUrl string
|
SmtpApiUrl string
|
||||||
SmtpHost string
|
SmtpHost string
|
||||||
SmtpPort string
|
SmtpPort string
|
||||||
SmtpSender string
|
SmtpSender string
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
ApiKey string
|
ApiKey string
|
||||||
FiberClient *fiber.Client
|
FiberClient *fiber.Client
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
CodewordHost string
|
RecoveryUrl string
|
||||||
CodewordPort string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type RecoveryEmailSender struct {
|
type RecoveryEmailSender struct {
|
||||||
@ -40,7 +39,7 @@ func (r *RecoveryEmailSender) SendRecoveryEmail(email string, signature string)
|
|||||||
|
|
||||||
fmt.Println(email, signature)
|
fmt.Println(email, signature)
|
||||||
|
|
||||||
message := fmt.Sprintf("http://"+r.deps.CodewordHost+":"+r.deps.CodewordPort+"/recover/%s", signature)
|
message := r.deps.RecoveryUrl + signature
|
||||||
|
|
||||||
form := new(bytes.Buffer)
|
form := new(bytes.Buffer)
|
||||||
writer := multipart.NewWriter(form)
|
writer := multipart.NewWriter(form)
|
||||||
@ -48,7 +47,7 @@ func (r *RecoveryEmailSender) SendRecoveryEmail(email string, signature string)
|
|||||||
|
|
||||||
fields := map[string]string{
|
fields := map[string]string{
|
||||||
"from": r.deps.SmtpSender,
|
"from": r.deps.SmtpSender,
|
||||||
"to": "pashamullin202@gmail.com",
|
"to": email,
|
||||||
"subject": "Восстановление доступа",
|
"subject": "Восстановление доступа",
|
||||||
"html": message,
|
"html": message,
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@ func (r *RecoveryController) HandleRecoveryRequest(c *fiber.Ctx) error {
|
|||||||
user, err := r.service.FindUserByEmail(c.Context(), req.Email)
|
user, err := r.service.FindUserByEmail(c.Context(), req.Email)
|
||||||
if err != nil || user == nil {
|
if err != nil || user == nil {
|
||||||
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"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,17 +8,16 @@ import (
|
|||||||
|
|
||||||
func RecoveryEmailSender(cfg Config, logger *zap.Logger) *client.RecoveryEmailSender {
|
func RecoveryEmailSender(cfg Config, logger *zap.Logger) *client.RecoveryEmailSender {
|
||||||
return client.NewRecoveryEmailSender(client.RecoveryEmailSenderDeps{
|
return client.NewRecoveryEmailSender(client.RecoveryEmailSenderDeps{
|
||||||
SmtpApiUrl: cfg.SmtpApiUrl,
|
SmtpApiUrl: cfg.SmtpApiUrl,
|
||||||
SmtpHost: cfg.SmtpHost,
|
SmtpHost: cfg.SmtpHost,
|
||||||
SmtpPort: cfg.SmtpPort,
|
SmtpPort: cfg.SmtpPort,
|
||||||
SmtpSender: cfg.SmtpSender,
|
SmtpSender: cfg.SmtpSender,
|
||||||
Username: cfg.SmtpUsername,
|
Username: cfg.SmtpUsername,
|
||||||
Password: cfg.SmtpPassword,
|
Password: cfg.SmtpPassword,
|
||||||
ApiKey: cfg.SmtpApiKey,
|
ApiKey: cfg.SmtpApiKey,
|
||||||
FiberClient: &fiber.Client{},
|
FiberClient: &fiber.Client{},
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
CodewordHost: cfg.HTTPHost,
|
RecoveryUrl: cfg.RecoveryUrl,
|
||||||
CodewordPort: cfg.HTTPPort,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ type Config struct {
|
|||||||
KafkaBrokers string `env:"KAFKA_BROKERS"`
|
KafkaBrokers string `env:"KAFKA_BROKERS"`
|
||||||
KafkaTopic string `env:"KAFKA_TOPIC_TARIFF"`
|
KafkaTopic string `env:"KAFKA_TOPIC_TARIFF"`
|
||||||
DiscountServiceAddress string `env:"DISCOUNT_ADDRESS"`
|
DiscountServiceAddress string `env:"DISCOUNT_ADDRESS"`
|
||||||
|
RecoveryUrl string `env:"RECOVERY_URL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConfig() (*Config, error) {
|
func LoadConfig() (*Config, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user