summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2015-07-07 17:57:25 -0700
committerReed Garmsen <rgarmsen2295@gmail.com>2015-07-07 17:57:25 -0700
commitddeb3ec7385c921e809b6c5ad337b23ea9ce8776 (patch)
tree575f9b6a49383b1990f5d5738c1040761f98d212 /api
parent66e97a56b0814b7c2378e9c7b4603d1c6408d330 (diff)
downloadchat-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.go9
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"])