0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Wiring up "resend" and "revoke" button on user management screen

fixes #3214
- new ```resendInvite``` method on the User model encapsulates all logic
- only sending users email address when re-inviting, since the user already exists on the back-end
- ```revoke``` calls DELETE on /ghost/api/v0.1/users/:user_id
This commit is contained in:
Maurice Williams 2014-07-08 01:24:07 -04:00
parent 2998e08e7b
commit 889239b326
2 changed files with 31 additions and 2 deletions

View file

@ -40,11 +40,28 @@ var SettingsUserController = Ember.ObjectController.extend({
actions: { actions: {
revoke: function () { revoke: function () {
alert('@TODO: revoke users invitation'); var self = this,
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.closePassive();
self.notifications.showAPIError(error);
});
}, },
resend: function () { resend: function () {
alert('@TODO: resend users invitation'); var self = this;
this.get('model').resendInvite().then(function () {
var notificationText = 'Invitation resent! (' + self.get('email') + ')';
self.notifications.showSuccess(notificationText, false);
}).catch(function (error) {
self.notifications.closePassive();
self.notifications.showAPIError(error);
});
}, },
save: function () { save: function () {

View file

@ -57,6 +57,18 @@ var User = DS.Model.extend({
}); });
}, },
resendInvite: function () {
var userData = {};
userData.email = this.get('email');
return ic.ajax.request(this.get('ghostPaths').apiUrl('users'), {
type: 'POST',
data: JSON.stringify({users: [userData]}),
contentType: 'application/json'
});
},
passwordValidationErrors: function (password) { passwordValidationErrors: function (password) {
var validationErrors = []; var validationErrors = [];