From 2db93a12c2124cd108d594fe0878af68608b7c66 Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Fri, 24 Jul 2020 12:56:32 +0200 Subject: [PATCH 1/2] ocm: pass the link to the meshdirectory service in token mail --- internal/http/services/ocmd/invites.go | 17 ++++++++++++++--- internal/http/services/ocmd/ocmd.go | 11 ++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/internal/http/services/ocmd/invites.go b/internal/http/services/ocmd/invites.go index 9b890f5785..20cd80170e 100644 --- a/internal/http/services/ocmd/invites.go +++ b/internal/http/services/ocmd/invites.go @@ -37,13 +37,15 @@ import ( ) type invitesHandler struct { - smtpCredentials *smtpclient.SMTPCredentials - gatewayAddr string + smtpCredentials *smtpclient.SMTPCredentials + gatewayAddr string + meshDirectoryURL string } func (h *invitesHandler) init(c *Config) { h.gatewayAddr = c.GatewaySvc h.smtpCredentials = smtpclient.NewSMTPCredentials(c.SMTPCredentials) + h.meshDirectoryURL = c.MeshDirectoryURL } func (h *invitesHandler) Handler() http.Handler { @@ -90,7 +92,9 @@ func (h *invitesHandler) generateInviteToken(w http.ResponseWriter, r *http.Requ subject := fmt.Sprintf("ScienceMesh: %s wants to collaborate with you", usr.DisplayName) body := "Hi,\n\n" + usr.DisplayName + " (" + usr.Mail + ") wants to start sharing OCM resources with you. " + - "To accept the invite, please use the following details:\n" + + "To accept the invite, please visit the following URL:\n" + + h.meshDirectoryURL + "?token=" + token.InviteToken.Token + "&providerDomain=" + usr.Id.Idp + "\n\n" + + "Alternatively, you can visit your mesh provider and use the following details:\n" + "Token: " + token.InviteToken.Token + "\n" + "ProviderDomain: " + usr.Id.Idp + "\n\n" + "Best,\nThe ScienceMesh team" @@ -164,6 +168,13 @@ func (h *invitesHandler) forwardInvite(w http.ResponseWriter, r *http.Request) { return } + _, err = w.Write([]byte("Accepted invite from: " + r.FormValue("providerDomain"))) + if err != nil { + WriteError(w, r, APIErrorServerError, "error writing token data", err) + return + } + w.WriteHeader(http.StatusOK) + log.Info().Msgf("Invite forwarded to: %s", r.FormValue("providerDomain")) } diff --git a/internal/http/services/ocmd/ocmd.go b/internal/http/services/ocmd/ocmd.go index 0e579ca5bf..88c731ac5d 100644 --- a/internal/http/services/ocmd/ocmd.go +++ b/internal/http/services/ocmd/ocmd.go @@ -32,11 +32,12 @@ import ( // Config holds the config options that need to be passed down to all ocdav handlers type Config struct { - SMTPCredentials *smtpclient.SMTPCredentials `mapstructure:"smtp_credentials"` - Prefix string `mapstructure:"prefix"` - Host string `mapstructure:"host"` - GatewaySvc string `mapstructure:"gatewaysvc"` - Config configData `mapstructure:"config"` + SMTPCredentials *smtpclient.SMTPCredentials `mapstructure:"smtp_credentials"` + Prefix string `mapstructure:"prefix"` + Host string `mapstructure:"host"` + GatewaySvc string `mapstructure:"gatewaysvc"` + MeshDirectoryURL string `mapstructure:"mesh_directory_url"` + Config configData `mapstructure:"config"` } func (c *Config) init() { From e96874408217ab9f122db761acbb0c1c349b3c7b Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Fri, 24 Jul 2020 13:01:39 +0200 Subject: [PATCH 2/2] Add changelog --- changelog/unreleased/ocm-token-mail-meshdir.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 changelog/unreleased/ocm-token-mail-meshdir.md diff --git a/changelog/unreleased/ocm-token-mail-meshdir.md b/changelog/unreleased/ocm-token-mail-meshdir.md new file mode 100644 index 0000000000..c0bd383ad1 --- /dev/null +++ b/changelog/unreleased/ocm-token-mail-meshdir.md @@ -0,0 +1,9 @@ +Enhancement: Pass the link to the meshdirectory service in token mail. + +Currently, we just forward the token and the original user's domain when +forwarding an OCM invite token and expect the user to frame the forward invite +URL. This PR instead passes the link to the meshdirectory service, from where +the user can pick the provider they want to accept the invite with. + +https://github.com/cs3org/reva/pull/1002 +https://github.com/sciencemesh/sciencemesh/issues/139