mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
Merge pull request #3593 from morficus/issue-3563
prevent revoking invite for already active users
This commit is contained in:
commit
2ac2cc3719
@ -63,13 +63,23 @@ var SettingsUserController = Ember.ObjectController.extend({
|
||||
},
|
||||
revoke: function () {
|
||||
var self = this,
|
||||
model = this.get('model'),
|
||||
email = this.get('email');
|
||||
|
||||
this.get('model').destroyRecord().then(function () {
|
||||
var notificationText = 'Invitation revoked. (' + email + ')';
|
||||
self.notifications.showSuccess(notificationText, false);
|
||||
}).catch(function (error) {
|
||||
self.notifications.showAPIError(error);
|
||||
//reload the model to get the most up-to-date user information
|
||||
model.reload().then(function () {
|
||||
if (self.get('invited')) {
|
||||
model.destroyRecord().then(function () {
|
||||
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});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -26,6 +26,12 @@ var UsersIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, Pag
|
||||
return true;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
reload: function () {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user