From ddeb3ec7385c921e809b6c5ad337b23ea9ce8776 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Tue, 7 Jul 2015 17:57:25 -0700 Subject: 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. --- web/react/components/invite_member_modal.jsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'web/react/components/invite_member_modal.jsx') diff --git a/web/react/components/invite_member_modal.jsx b/web/react/components/invite_member_modal.jsx index d1672126d..bfcbfc94f 100644 --- a/web/react/components/invite_member_modal.jsx +++ b/web/react/components/invite_member_modal.jsx @@ -43,6 +43,7 @@ module.exports = React.createClass({ var first_name_errors = this.state.first_name_errors; var last_name_errors = this.state.last_name_errors; var valid = true; + var profiles = UserStore.getProfiles(); for (var i = 0; i < count; i++) { var index = invite_ids[i]; @@ -52,6 +53,13 @@ module.exports = React.createClass({ email_errors[index] = "Please enter a valid email address"; valid = false; } else { + for (var email in profiles) { + if (email === invite.email) { + email_errors[index] = "This person is already on your team"; + valid = false; + } + } + email_errors[index] = ""; } @@ -89,7 +97,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) ); @@ -138,7 +151,8 @@ module.exports = React.createClass({ id_count: 0, email_errors: {}, first_name_errors: {}, - last_name_errors: {} + last_name_errors: {}, + server_errors: {} }; }, render: function() { -- cgit v1.2.3-1-g7c22 From 65dc307e685ad4a0b6df4263edd3f6b890ddd207 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Tue, 7 Jul 2015 18:12:53 -0700 Subject: Small tweaks and cleanup --- web/react/components/invite_member_modal.jsx | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'web/react/components/invite_member_modal.jsx') diff --git a/web/react/components/invite_member_modal.jsx b/web/react/components/invite_member_modal.jsx index bfcbfc94f..9ff67ae1b 100644 --- a/web/react/components/invite_member_modal.jsx +++ b/web/react/components/invite_member_modal.jsx @@ -43,7 +43,6 @@ module.exports = React.createClass({ var first_name_errors = this.state.first_name_errors; var last_name_errors = this.state.last_name_errors; var valid = true; - var profiles = UserStore.getProfiles(); for (var i = 0; i < count; i++) { var index = invite_ids[i]; @@ -53,13 +52,6 @@ module.exports = React.createClass({ email_errors[index] = "Please enter a valid email address"; valid = false; } else { - for (var email in profiles) { - if (email === invite.email) { - email_errors[index] = "This person is already on your team"; - valid = false; - } - } - email_errors[index] = ""; } @@ -151,8 +143,7 @@ module.exports = React.createClass({ id_count: 0, email_errors: {}, first_name_errors: {}, - last_name_errors: {}, - server_errors: {} + last_name_errors: {} }; }, render: function() { -- cgit v1.2.3-1-g7c22