From 7be359b5637a5c3be73b1a6284063f60afe5811d Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Wed, 8 Jul 2020 12:27:09 +0200 Subject: [PATCH] Read SMTP password from env if not set in config --- internal/http/services/ocmd/invites.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/http/services/ocmd/invites.go b/internal/http/services/ocmd/invites.go index b25690da3fb..ff174246a64 100644 --- a/internal/http/services/ocmd/invites.go +++ b/internal/http/services/ocmd/invites.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" "net/http" + "os" userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" invitepb "github.com/cs3org/go-cs3apis/cs3/ocm/invite/v1beta1" @@ -44,6 +45,9 @@ type invitesHandler struct { func (h *invitesHandler) init(c *Config) { h.gatewayAddr = c.GatewaySvc h.smtpCredentials = c.SMTPCredentials + if h.smtpCredentials.SenderPassword == "" { + h.smtpCredentials.SenderPassword = os.Getenv("REVA_OCMD_SMTP_SENDER_PASSWORD") + } } func (h *invitesHandler) Handler() http.Handler { @@ -83,13 +87,14 @@ func (h *invitesHandler) generateInviteToken(w http.ResponseWriter, r *http.Requ } if r.FormValue("recipient") != "" && h.smtpCredentials != nil { + usr := user.ContextMustGetUser(ctx) username := usr.DisplayName // TODO: the message body needs to point to the meshdirectory service subject := fmt.Sprintf("ScienceMesh: %s wants to collaborate with you", username) body := "Hi,\n\n" + - username + " wants to start sharing OCM resources with you. " + + usr.DisplayName + " (" + usr.Mail + ") wants to start sharing OCM resources with you. " + "To accept the invite, please use the following details:\n" + "Token: " + token.InviteToken.Token + "\n" + "ProviderDomain: " + usr.Id.Idp + "\n\n" +