Skip to content

Commit

Permalink
make verify email domain configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed Aug 31, 2022
1 parent 26db77a commit 383dc0d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions user/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Domain struct {
store store.Store
sengridKey string
fromEmail string
verifyUrl string
}

var (
Expand All @@ -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("")
Expand All @@ -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 {
Expand All @@ -76,6 +81,7 @@ func New(st store.Store) *Domain {
sengridKey: key,
store: st,
fromEmail: email,
verifyUrl: url,
}
}

Expand All @@ -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
Expand Down

0 comments on commit 383dc0d

Please sign in to comment.