mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Move user API to primary document format
closes #2593 - added new format to user API methods - changed all places where the user api was used - updated tests and added more coverage - little bit of cleanup in utils/api
This commit is contained in:
parent
21acce5391
commit
2d95159a6f
1 changed files with 21 additions and 2 deletions
|
@ -1,9 +1,28 @@
|
|||
/*global Ghost */
|
||||
/*global Ghost,Backbone */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
Ghost.Models.User = Ghost.ProgressModel.extend({
|
||||
url: Ghost.paths.apiRoot + '/users/me/'
|
||||
url: Ghost.paths.apiRoot + '/users/me/',
|
||||
|
||||
parse: function (resp) {
|
||||
// unwrap user from {users: [{...}]}
|
||||
if (resp.users) {
|
||||
resp = resp.users[0];
|
||||
}
|
||||
|
||||
return resp;
|
||||
},
|
||||
|
||||
sync: function (method, model, options) {
|
||||
// wrap user in {users: [{...}]}
|
||||
if (method === 'create' || method === 'update') {
|
||||
options.data = JSON.stringify({users: [this.attributes]});
|
||||
options.contentType = 'application/json';
|
||||
}
|
||||
|
||||
return Backbone.Model.prototype.sync.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
||||
// Ghost.Collections.Users = Backbone.Collection.extend({
|
||||
|
|
Loading…
Add table
Reference in a new issue