Skip to content

Commit 889239b

Browse files
committed
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
1 parent 2998e08 commit 889239b

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

core/client/controllers/settings/users/user.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,28 @@ var SettingsUserController = Ember.ObjectController.extend({
4040

4141
actions: {
4242
revoke: function () {
43-
alert('@TODO: revoke users invitation');
43+
var self = this,
44+
email = this.get('email');
45+
46+
this.get('model').destroyRecord().then(function () {
47+
var notificationText = 'Invitation revoked. (' + email + ')';
48+
self.notifications.showSuccess(notificationText, false);
49+
}).catch(function (error) {
50+
self.notifications.closePassive();
51+
self.notifications.showAPIError(error);
52+
});
4453
},
4554

4655
resend: function () {
47-
alert('@TODO: resend users invitation');
56+
var self = this;
57+
58+
this.get('model').resendInvite().then(function () {
59+
var notificationText = 'Invitation resent! (' + self.get('email') + ')';
60+
self.notifications.showSuccess(notificationText, false);
61+
}).catch(function (error) {
62+
self.notifications.closePassive();
63+
self.notifications.showAPIError(error);
64+
});
4865
},
4966

5067
save: function () {

core/client/models/user.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ var User = DS.Model.extend({
5757
});
5858
},
5959

60+
resendInvite: function () {
61+
var userData = {};
62+
63+
userData.email = this.get('email');
64+
65+
return ic.ajax.request(this.get('ghostPaths').apiUrl('users'), {
66+
type: 'POST',
67+
data: JSON.stringify({users: [userData]}),
68+
contentType: 'application/json'
69+
});
70+
},
71+
6072
passwordValidationErrors: function (password) {
6173
var validationErrors = [];
6274

0 commit comments

Comments
 (0)