From 896ea8e1770ac61af158ce133fad908e43c995a6 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sat, 16 May 2015 13:30:57 +0530 Subject: [PATCH] FIX: trim leading/trailing spaces from invite email --- .../javascripts/discourse/controllers/invite.js.es6 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/invite.js.es6 b/app/assets/javascripts/discourse/controllers/invite.js.es6 index ac1cc0628..1f7179111 100644 --- a/app/assets/javascripts/discourse/controllers/invite.js.es6 +++ b/app/assets/javascripts/discourse/controllers/invite.js.es6 @@ -16,12 +16,13 @@ export default ObjectController.extend(Presence, ModalFunctionality, { disabled: function() { if (this.get('saving')) return true; if (this.blank('emailOrUsername')) return true; + const emailOrUsername = this.get('emailOrUsername').trim(); // when inviting to forum, email must be valid - if (!this.get('invitingToTopic') && !Discourse.Utilities.emailValid(this.get('emailOrUsername'))) return true; + if (!this.get('invitingToTopic') && !Discourse.Utilities.emailValid(emailOrUsername)) return true; // normal users (not admin) can't invite users to private topic via email - if (!this.get('isAdmin') && this.get('isPrivateTopic') && Discourse.Utilities.emailValid(this.get('emailOrUsername'))) return true; + if (!this.get('isAdmin') && this.get('isPrivateTopic') && Discourse.Utilities.emailValid(emailOrUsername)) return true; // when invting to private topic via email, group name must be specified - if (this.get('isPrivateTopic') && this.blank('groupNames') && Discourse.Utilities.emailValid(this.get('emailOrUsername'))) return true; + if (this.get('isPrivateTopic') && this.blank('groupNames') && Discourse.Utilities.emailValid(emailOrUsername)) return true; if (this.get('model.details.can_invite_to')) return false; return false; }.property('isAdmin', 'emailOrUsername', 'invitingToTopic', 'isPrivateTopic', 'groupNames', 'saving'), @@ -135,7 +136,7 @@ export default ObjectController.extend(Presence, ModalFunctionality, { this.setProperties({ saving: true, error: false }); - return this.get('model').createInvite(this.get('emailOrUsername'), groupNames).then(result => { + return this.get('model').createInvite(this.get('emailOrUsername').trim(), groupNames).then(result => { this.setProperties({ saving: false, finished: true }); if (!this.get('invitingToTopic')) { Discourse.Invite.findInvitedBy(Discourse.User.current()).then(invite_model => {