diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-07-08 20:24:39 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-07-08 20:24:39 -0400 |
commit | 3ad209892635e733c90dd3d669491051276766bd (patch) | |
tree | 35537e57f5cfff4d71291fca64808ab3f09f04fa | |
parent | 11dde6c44bbb39e88969eb1691cfcf9e21f5ad08 (diff) | |
parent | 65dc307e685ad4a0b6df4263edd3f6b890ddd207 (diff) | |
download | chat-3ad209892635e733c90dd3d669491051276766bd.tar.gz chat-3ad209892635e733c90dd3d669491051276766bd.tar.bz2 chat-3ad209892635e733c90dd3d669491051276766bd.zip |
Merge pull request #149 from rgarmsen2295/mm-1260
MM-1260 Member Invites can no longer be sent to emails already used to signup
-rw-r--r-- | api/team.go | 9 | ||||
-rw-r--r-- | web/react/components/invite_member_modal.jsx | 7 |
2 files changed, 15 insertions, 1 deletions
diff --git a/api/team.go b/api/team.go index 15e4e2c17..c4a0ca181 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 i, 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" { + invNum = int64(i) + c.Err = model.NewAppError("invite_members", "This person is already on your team", strconv.FormatInt(invNum, 10)) + return + } + } + ia := make([]string, len(invites.Invites)) for _, invite := range invites.Invites { ia = append(ia, invite["email"]) diff --git a/web/react/components/invite_member_modal.jsx b/web/react/components/invite_member_modal.jsx index d1672126d..9ff67ae1b 100644 --- a/web/react/components/invite_member_modal.jsx +++ b/web/react/components/invite_member_modal.jsx @@ -89,7 +89,12 @@ module.exports = React.createClass({ $(this.refs.modal.getDOMNode()).modal('hide'); }.bind(this), function(err) { - this.setState({ server_error: err }); + if (err.message === "This person is already on your team") { + email_errors[err.detailed_error] = err.message; + this.setState({ email_errors: email_errors }); + } + else + this.setState({ server_error: err.message}); }.bind(this) ); |