mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
Transfer ownership end point
closes #3426 - added transfer ownership endpoint - added owner to roles.permissible - manually removed owner from roles.browse - removed hard coded author role - fixed tests that were passing due to hard coded author role - added testUtils.setup(‚roles‘)
This commit is contained in:
parent
11c0fe7a0f
commit
a18b58a2f6
@ -2,27 +2,24 @@ var TransferOwnerController = Ember.Controller.extend({
|
|||||||
actions: {
|
actions: {
|
||||||
confirmAccept: function () {
|
confirmAccept: function () {
|
||||||
var user = this.get('model'),
|
var user = this.get('model'),
|
||||||
|
url = this.get('ghostPaths.url').api('users', 'owner'),
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
self.get('popover').closePopovers();
|
self.get('popover').closePopovers();
|
||||||
|
|
||||||
// Get owner role
|
ic.ajax.request(url, {
|
||||||
this.store.find('role').then(function (result) {
|
type: 'PUT',
|
||||||
return result.findBy('name', 'Owner');
|
data: {
|
||||||
}).then(function (ownerRole) {
|
owner: [{
|
||||||
// remove roles and assign owner role
|
'id': user.get('id')
|
||||||
user.get('roles').clear();
|
}]
|
||||||
user.get('roles').pushObject(ownerRole);
|
}
|
||||||
|
|
||||||
return user.saveOnly('roles');
|
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
self.notifications.closePassive();
|
self.notifications.closePassive();
|
||||||
self.notifications.showSuccess('Ownership successfully transferred to ' + user.get('name'));
|
self.notifications.showSuccess('Ownership successfully transferred to ' + user.get('name'));
|
||||||
}).catch(function (errors) {
|
}).catch(function (error) {
|
||||||
self.notifications.closePassive();
|
self.notifications.closePassive();
|
||||||
|
self.notifications.showAPIError(error);
|
||||||
errors = Ember.isArray(errors) ? errors : Ember.A([errors]);
|
|
||||||
self.notifications.showErrors(errors);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user