Skip to content

Commit

Permalink
Read SMTP password from env if not set in config
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Jul 8, 2020
1 parent 1627360 commit 7be359b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/http/services/ocmd/invites.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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" +
Expand Down

0 comments on commit 7be359b

Please sign in to comment.