mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
1db0431e4d
closes #2822 - added destroy user method - added remove user permission - added API end point for get reset token - added API end point for reset password - added API end point for change password
25 lines
766 B
JavaScript
25 lines
766 B
JavaScript
// # API Utils
|
|
// Shared helpers for working with the API
|
|
var when = require('when'),
|
|
_ = require('lodash'),
|
|
errors = require('../errors'),
|
|
utils;
|
|
|
|
utils = {
|
|
/**
|
|
* ### Check Object
|
|
* Check an object passed to the API is in the correct format
|
|
*
|
|
* @param {Object} object
|
|
* @param {String} docName
|
|
* @returns {Promise(Object)} resolves to the original object if it checks out
|
|
*/
|
|
checkObject: function (object, docName) {
|
|
if (_.isEmpty(object) || _.isEmpty(object[docName]) || _.isEmpty(object[docName][0])) {
|
|
return when.reject(new errors.BadRequestError('No root key (\'' + docName + '\') provided.'));
|
|
}
|
|
return when.resolve(object);
|
|
}
|
|
};
|
|
|
|
module.exports = utils; |