diff options
author | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-07-07 17:57:25 -0700 |
---|---|---|
committer | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-07-07 17:57:25 -0700 |
commit | ddeb3ec7385c921e809b6c5ad337b23ea9ce8776 (patch) | |
tree | 575f9b6a49383b1990f5d5738c1040761f98d212 /api | |
parent | 66e97a56b0814b7c2378e9c7b4603d1c6408d330 (diff) | |
download | chat-ddeb3ec7385c921e809b6c5ad337b23ea9ce8776.tar.gz chat-ddeb3ec7385c921e809b6c5ad337b23ea9ce8776.tar.bz2 chat-ddeb3ec7385c921e809b6c5ad337b23ea9ce8776.zip |
Added a server side check to see if members who are trying to be invited have already been invited by checking the email. Client handles it as if it was an email error.
Diffstat (limited to 'api')
-rw-r--r-- | api/team.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/api/team.go b/api/team.go index 15e4e2c17..7265b1d07 100644 --- a/api/team.go +++ b/api/team.go @@ -456,6 +456,15 @@ func inviteMembers(c *Context, w http.ResponseWriter, r *http.Request) { user = result.Data.(*model.User) } + var invNum int64 = 0 + for _, invite := range invites.Invites { + if result := <-Srv.Store.User().GetByEmail(c.Session.TeamId, invite["email"]); result.Err == nil || result.Err.Message != "We couldn't find the existing account" { + c.Err = model.NewAppError("invite_members", "This person is already on your team", strconv.FormatInt(invNum, 10)) + return + } + invNum++; + } + ia := make([]string, len(invites.Invites)) for _, invite := range invites.Invites { ia = append(ia, invite["email"]) |