From 383dc0d8df94350568db04810e9f862730e27f42 Mon Sep 17 00:00:00 2001 From: asim Date: Wed, 31 Aug 2022 12:19:06 +0100 Subject: [PATCH] make verify email domain configurable --- user/domain/domain.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/user/domain/domain.go b/user/domain/domain.go index 3f44e5506d..4c428a65c2 100644 --- a/user/domain/domain.go +++ b/user/domain/domain.go @@ -50,6 +50,7 @@ type Domain struct { store store.Store sengridKey string fromEmail string + verifyUrl string } var ( @@ -58,7 +59,7 @@ var ( ) func New(st store.Store) *Domain { - var key, email string + var key, email, url string cfg, err := config.Get("micro.user.sendgrid.api_key") if err == nil { key = cfg.String("") @@ -67,6 +68,10 @@ func New(st store.Store) *Domain { if err == nil { email = cfg.String(defaultSender) } + cfg, err = config.Get("micro.user.verify_email_url") + if err == nil { + url = cfg.String("http://localhost:8080/user/VerifyEmail") + } if len(key) == 0 { logger.Info("No email key found") } else { @@ -76,6 +81,7 @@ func New(st store.Store) *Domain { sengridKey: key, store: st, fromEmail: email, + verifyUrl: url, } } @@ -86,7 +92,7 @@ func (domain *Domain) SendEmail(fromName, toAddress, toUsername, subject, textCo from := mail.NewEmail(fromName, domain.fromEmail) to := mail.NewEmail(toUsername, toAddress) - uri := "https://user.m3o.com" + uri := domain.verifyUrl query := "?token=" + token + "&redirectUrl=" + url.QueryEscape(redirctUrl) + "&failureRedirectUrl=" + url.QueryEscape(failureRedirectUrl) // set the text content