prevent revoking invite for already active users

closes #3563
- before attempting to revoke an invitation, get updated model info
- reload route and show warning if user info has changed
This commit is contained in:
Maurice Williams 2014-08-02 20:49:56 -04:00 committed by Maurice Williams
parent aea25693e5
commit 18a1be8850
2 changed files with 21 additions and 5 deletions

View File

@ -63,13 +63,23 @@ var SettingsUserController = Ember.ObjectController.extend({
}, },
revoke: function () { revoke: function () {
var self = this, var self = this,
model = this.get('model'),
email = this.get('email'); email = this.get('email');
this.get('model').destroyRecord().then(function () { //reload the model to get the most up-to-date user information
var notificationText = 'Invitation revoked. (' + email + ')'; model.reload().then(function () {
self.notifications.showSuccess(notificationText, false); if (self.get('invited')) {
}).catch(function (error) { model.destroyRecord().then(function () {
self.notifications.showAPIError(error); var notificationText = 'Invitation revoked. (' + email + ')';
self.notifications.showSuccess(notificationText, false);
}).catch(function (error) {
self.notifications.showAPIError(error);
});
} else {
//if the user is no longer marked as "invited", then show a warning and reload the route
self.get('target').send('reload');
self.notifications.showError('This user has already accepted the invitation.', {delayed: 500});
}
}); });
}, },

View File

@ -26,6 +26,12 @@ var UsersIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, Pag
return true; return true;
}); });
}); });
},
actions: {
reload: function () {
this.refresh();
}
} }
}); });