mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Renamed apiUtils to localUtils - consistency change
refs #9178 - we should always use the same naming patterns
This commit is contained in:
parent
6e915e8e89
commit
0d65e7f24f
17 changed files with 117 additions and 117 deletions
|
@ -5,7 +5,7 @@ var Promise = require('bluebird'),
|
|||
mail = require('./../mail'),
|
||||
globalUtils = require('../utils'),
|
||||
urlService = require('../services/url'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
config = require('../config'),
|
||||
common = require('../lib/common'),
|
||||
|
@ -59,7 +59,7 @@ function setupTasks(setupData) {
|
|||
var tasks;
|
||||
|
||||
function validateData(setupData) {
|
||||
return apiUtils.checkObject(setupData, 'setup').then(function then(checked) {
|
||||
return localUtils.checkObject(setupData, 'setup').then(function then(checked) {
|
||||
var data = checked.setup[0];
|
||||
|
||||
return {
|
||||
|
@ -139,7 +139,7 @@ authentication = {
|
|||
var tasks;
|
||||
|
||||
function validateRequest(object) {
|
||||
return apiUtils.checkObject(object, 'passwordreset').then(function then(data) {
|
||||
return localUtils.checkObject(object, 'passwordreset').then(function then(data) {
|
||||
var email = data.passwordreset[0].email;
|
||||
|
||||
if (typeof email !== 'string' || !validator.isEmail(email)) {
|
||||
|
@ -236,7 +236,7 @@ authentication = {
|
|||
var tasks, tokenIsCorrect, dbHash, options = {context: {internal: true}}, tokenParts;
|
||||
|
||||
function validateRequest() {
|
||||
return apiUtils.validate('passwordreset')(object, options)
|
||||
return localUtils.validate('passwordreset')(object, options)
|
||||
.then(function (options) {
|
||||
var data = options.data.passwordreset[0];
|
||||
|
||||
|
@ -359,7 +359,7 @@ authentication = {
|
|||
var tasks, invite, options = {context: {internal: true}};
|
||||
|
||||
function validateInvitation(invitation) {
|
||||
return apiUtils.checkObject(invitation, 'invitation')
|
||||
return localUtils.checkObject(invitation, 'invitation')
|
||||
.then(function () {
|
||||
if (!invitation.invitation[0].token) {
|
||||
return Promise.reject(new common.errors.ValidationError({message: common.i18n.t('errors.api.authentication.noTokenProvided')}));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var Promise = require('bluebird'),
|
||||
_ = require('lodash'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
docName = 'clients',
|
||||
|
@ -51,7 +51,7 @@ clients = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {attrs: attrs}),
|
||||
localUtils.validate(docName, {attrs: attrs}),
|
||||
// TODO: add permissions
|
||||
// utils.handlePublicPermissions(docName, 'read'),
|
||||
doQuery
|
||||
|
|
|
@ -4,7 +4,7 @@ var Promise = require('bluebird'),
|
|||
path = require('path'),
|
||||
fs = require('fs-extra'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
exporter = require('../data/export'),
|
||||
importer = require('../data/importer'),
|
||||
backupDatabase = require('../data/db/backup'),
|
||||
|
@ -67,7 +67,7 @@ db = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.handlePermissions(docName, 'exportContent'),
|
||||
localUtils.handlePermissions(docName, 'exportContent'),
|
||||
exportContent
|
||||
];
|
||||
|
||||
|
@ -94,7 +94,7 @@ db = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.handlePermissions(docName, 'importContent'),
|
||||
localUtils.handlePermissions(docName, 'importContent'),
|
||||
importContent
|
||||
];
|
||||
|
||||
|
@ -129,7 +129,7 @@ db = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.handlePermissions(docName, 'deleteAllContent'),
|
||||
localUtils.handlePermissions(docName, 'deleteAllContent'),
|
||||
backupDatabase,
|
||||
deleteContent
|
||||
];
|
||||
|
|
|
@ -4,7 +4,7 @@ var Promise = require('bluebird'),
|
|||
mail = require('./../mail'),
|
||||
globalUtils = require('../utils'),
|
||||
urlService = require('../services/url'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
mailAPI = require('./mail'),
|
||||
|
@ -22,9 +22,9 @@ invites = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.browseDefaultOptions}),
|
||||
apiUtils.handlePublicPermissions(docName, 'browse'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: localUtils.browseDefaultOptions}),
|
||||
localUtils.handlePublicPermissions(docName, 'browse'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
modelQuery
|
||||
];
|
||||
|
||||
|
@ -51,9 +51,9 @@ invites = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {attrs: attrs}),
|
||||
apiUtils.handlePublicPermissions(docName, 'read'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {attrs: attrs}),
|
||||
localUtils.handlePublicPermissions(docName, 'read'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
modelQuery
|
||||
];
|
||||
|
||||
|
@ -75,9 +75,9 @@ invites = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.idDefaultOptions}),
|
||||
apiUtils.handlePermissions(docName, 'destroy'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: localUtils.idDefaultOptions}),
|
||||
localUtils.handlePermissions(docName, 'destroy'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
modelQuery
|
||||
];
|
||||
|
||||
|
@ -233,9 +233,9 @@ invites = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: ['email']}),
|
||||
apiUtils.handlePermissions(docName, 'add'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: ['email']}),
|
||||
localUtils.handlePermissions(docName, 'add'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
fetchLoggedInUser,
|
||||
validation,
|
||||
checkIfUserExists,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
var Promise = require('bluebird'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
mail = require('../mail'),
|
||||
|
@ -85,7 +85,7 @@ apiMail = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.handlePermissions(docName, 'send'),
|
||||
localUtils.handlePermissions(docName, 'send'),
|
||||
send,
|
||||
formatResponse
|
||||
];
|
||||
|
|
|
@ -6,7 +6,7 @@ var Promise = require('bluebird'),
|
|||
pipeline = require('../utils/pipeline'),
|
||||
permissions = require('../permissions'),
|
||||
canThis = permissions.canThis,
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
common = require('../lib/common'),
|
||||
settingsAPI = require('./settings'),
|
||||
// Holds the persistent notifications
|
||||
|
@ -108,7 +108,7 @@ notifications = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.validate('notifications'),
|
||||
localUtils.validate('notifications'),
|
||||
handlePermissions,
|
||||
saveNotifications
|
||||
];
|
||||
|
@ -184,7 +184,7 @@ notifications = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.validate('notifications', {opts: apiUtils.idDefaultOptions}),
|
||||
localUtils.validate('notifications', {opts: localUtils.idDefaultOptions}),
|
||||
handlePermissions,
|
||||
destroyNotification
|
||||
];
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var Promise = require('bluebird'),
|
||||
_ = require('lodash'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
docName = 'posts',
|
||||
|
@ -44,7 +44,7 @@ posts = {
|
|||
if (options && options.context && (options.context.user || options.context.internal)) {
|
||||
extraOptions.push('staticPages');
|
||||
}
|
||||
permittedOptions = apiUtils.browseDefaultOptions.concat(extraOptions);
|
||||
permittedOptions = localUtils.browseDefaultOptions.concat(extraOptions);
|
||||
|
||||
/**
|
||||
* ### Model Query
|
||||
|
@ -58,9 +58,9 @@ posts = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: permittedOptions}),
|
||||
apiUtils.handlePublicPermissions(docName, 'browse', unsafeAttrs),
|
||||
apiUtils.convertOptions(allowedIncludes, models.Post.allowedFormats),
|
||||
localUtils.validate(docName, {opts: permittedOptions}),
|
||||
localUtils.handlePublicPermissions(docName, 'browse', unsafeAttrs),
|
||||
localUtils.convertOptions(allowedIncludes, models.Post.allowedFormats),
|
||||
modelQuery
|
||||
];
|
||||
|
||||
|
@ -105,9 +105,9 @@ posts = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {attrs: attrs, opts: extraAllowedOptions}),
|
||||
apiUtils.handlePublicPermissions(docName, 'read', unsafeAttrs),
|
||||
apiUtils.convertOptions(allowedIncludes, models.Post.allowedFormats),
|
||||
localUtils.validate(docName, {attrs: attrs, opts: extraAllowedOptions}),
|
||||
localUtils.handlePublicPermissions(docName, 'read', unsafeAttrs),
|
||||
localUtils.convertOptions(allowedIncludes, models.Post.allowedFormats),
|
||||
modelQuery
|
||||
];
|
||||
|
||||
|
@ -161,9 +161,9 @@ posts = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.idDefaultOptions.concat(extraAllowedOptions)}),
|
||||
apiUtils.handlePermissions(docName, 'edit', unsafeAttrs),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: localUtils.idDefaultOptions.concat(extraAllowedOptions)}),
|
||||
localUtils.handlePermissions(docName, 'edit', unsafeAttrs),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
modelQuery
|
||||
];
|
||||
|
||||
|
@ -205,9 +205,9 @@ posts = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName),
|
||||
apiUtils.handlePermissions(docName, 'add', unsafeAttrs),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName),
|
||||
localUtils.handlePermissions(docName, 'add', unsafeAttrs),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
modelQuery
|
||||
];
|
||||
|
||||
|
@ -244,9 +244,9 @@ posts = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.idDefaultOptions}),
|
||||
apiUtils.handlePermissions(docName, 'destroy', unsafeAttrs),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: localUtils.idDefaultOptions}),
|
||||
localUtils.handlePermissions(docName, 'destroy', unsafeAttrs),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
deletePost
|
||||
];
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ const fs = require('fs-extra'),
|
|||
config = require('../config'),
|
||||
common = require('../lib/common'),
|
||||
globalUtils = require('../utils'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
customRedirectsMiddleware = require('../web/middleware/custom-redirects');
|
||||
|
||||
let redirectsAPI,
|
||||
|
@ -45,7 +45,7 @@ _private.readRedirectsFile = function readRedirectsFile(customRedirectsPath) {
|
|||
|
||||
redirectsAPI = {
|
||||
download: function download(options) {
|
||||
return apiUtils.handlePermissions('redirects', 'download')(options)
|
||||
return localUtils.handlePermissions('redirects', 'download')(options)
|
||||
.then(function () {
|
||||
return _private.readRedirectsFile();
|
||||
});
|
||||
|
@ -54,7 +54,7 @@ redirectsAPI = {
|
|||
let redirectsPath = path.join(config.getContentPath('data'), 'redirects.json'),
|
||||
backupRedirectsPath = path.join(config.getContentPath('data'), `redirects-${moment().format('YYYY-MM-DD-HH-mm-ss')}.json`);
|
||||
|
||||
return apiUtils.handlePermissions('redirects', 'upload')(options)
|
||||
return localUtils.handlePermissions('redirects', 'upload')(options)
|
||||
.then(function backupOldRedirectsFile() {
|
||||
return fs.pathExists(redirectsPath)
|
||||
.then(function (exists) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// RESTful API for the Role resource
|
||||
var Promise = require('bluebird'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
canThis = require('../permissions').canThis,
|
||||
models = require('../models'),
|
||||
docName = 'roles',
|
||||
|
@ -65,8 +65,8 @@ roles = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: permittedOptions}),
|
||||
apiUtils.handlePermissions(docName, 'browse'),
|
||||
localUtils.validate(docName, {opts: permittedOptions}),
|
||||
localUtils.handlePermissions(docName, 'browse'),
|
||||
modelQuery
|
||||
];
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ var Promise = require('bluebird'),
|
|||
_ = require('lodash'),
|
||||
moment = require('moment'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
config = require('../config'),
|
||||
common = require('../lib/common'),
|
||||
|
@ -34,7 +34,7 @@ exports.publishPost = function publishPost(object, options) {
|
|||
options.context = {internal: true};
|
||||
|
||||
return pipeline([
|
||||
apiUtils.validate('posts', {opts: apiUtils.idDefaultOptions}),
|
||||
localUtils.validate('posts', {opts: localUtils.idDefaultOptions}),
|
||||
function (cleanOptions) {
|
||||
cleanOptions.status = 'scheduled';
|
||||
|
||||
|
@ -79,7 +79,7 @@ exports.getScheduledPosts = function readPosts(options) {
|
|||
options.context = {internal: true};
|
||||
|
||||
return pipeline([
|
||||
apiUtils.validate('posts', {opts: ['from', 'to']}),
|
||||
localUtils.validate('posts', {opts: ['from', 'to']}),
|
||||
function (cleanOptions) {
|
||||
cleanOptions.filter = 'status:scheduled';
|
||||
cleanOptions.columns = ['id', 'published_at', 'created_at'];
|
||||
|
|
|
@ -4,7 +4,7 @@ var Promise = require('bluebird'),
|
|||
_ = require('lodash'),
|
||||
models = require('../models'),
|
||||
canThis = require('../permissions').canThis,
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
common = require('../lib/common'),
|
||||
settingsCache = require('../settings/cache'),
|
||||
docName = 'settings',
|
||||
|
@ -225,7 +225,7 @@ settings = {
|
|||
});
|
||||
|
||||
return canEditAllSettings(object.settings, options).then(function () {
|
||||
return apiUtils.checkObject(object, docName).then(function (checkedData) {
|
||||
return localUtils.checkObject(object, docName).then(function (checkedData) {
|
||||
options.user = self.user;
|
||||
return models.Settings.edit(checkedData.settings, options);
|
||||
}).then(function (settingsModelsArray) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// RESTful API for the Slug resource
|
||||
var Promise = require('bluebird'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
docName = 'slugs',
|
||||
|
@ -72,8 +72,8 @@ slugs = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: opts, attrs: attrs}),
|
||||
apiUtils.handlePermissions(docName, 'generate'),
|
||||
localUtils.validate(docName, {opts: opts, attrs: attrs}),
|
||||
localUtils.handlePermissions(docName, 'generate'),
|
||||
checkAllowedTypes,
|
||||
modelQuery
|
||||
];
|
||||
|
|
|
@ -5,7 +5,7 @@ var Promise = require('bluebird'),
|
|||
fs = require('fs-extra'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
globalUtils = require('../utils'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
docName = 'subscribers',
|
||||
|
@ -37,8 +37,8 @@ subscribers = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.browseDefaultOptions}),
|
||||
apiUtils.handlePermissions(docName, 'browse'),
|
||||
localUtils.validate(docName, {opts: localUtils.browseDefaultOptions}),
|
||||
localUtils.handlePermissions(docName, 'browse'),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -78,8 +78,8 @@ subscribers = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {attrs: attrs}),
|
||||
apiUtils.handlePermissions(docName, 'read'),
|
||||
localUtils.validate(docName, {attrs: attrs}),
|
||||
localUtils.handlePermissions(docName, 'read'),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -128,8 +128,8 @@ subscribers = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName),
|
||||
apiUtils.handlePermissions(docName, 'add'),
|
||||
localUtils.validate(docName),
|
||||
localUtils.handlePermissions(docName, 'add'),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -170,8 +170,8 @@ subscribers = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.idDefaultOptions}),
|
||||
apiUtils.handlePermissions(docName, 'edit'),
|
||||
localUtils.validate(docName, {opts: localUtils.idDefaultOptions}),
|
||||
localUtils.handlePermissions(docName, 'edit'),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -223,8 +223,8 @@ subscribers = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: ['id', 'email']}),
|
||||
apiUtils.handlePermissions(docName, 'destroy'),
|
||||
localUtils.validate(docName, {opts: ['id', 'email']}),
|
||||
localUtils.handlePermissions(docName, 'destroy'),
|
||||
getSubscriberByEmail,
|
||||
doQuery
|
||||
];
|
||||
|
@ -279,7 +279,7 @@ subscribers = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.handlePermissions(docName, 'browse'),
|
||||
localUtils.handlePermissions(docName, 'browse'),
|
||||
exportSubscribers
|
||||
];
|
||||
|
||||
|
@ -341,7 +341,7 @@ subscribers = {
|
|||
}
|
||||
|
||||
tasks = [
|
||||
apiUtils.handlePermissions(docName, 'add'),
|
||||
localUtils.handlePermissions(docName, 'add'),
|
||||
importCSV
|
||||
];
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var Promise = require('bluebird'),
|
||||
_ = require('lodash'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
docName = 'tags',
|
||||
|
@ -36,9 +36,9 @@ tags = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.browseDefaultOptions}),
|
||||
apiUtils.handlePublicPermissions(docName, 'browse'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: localUtils.browseDefaultOptions}),
|
||||
localUtils.handlePublicPermissions(docName, 'browse'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -78,9 +78,9 @@ tags = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {attrs: attrs}),
|
||||
apiUtils.handlePublicPermissions(docName, 'read'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {attrs: attrs}),
|
||||
localUtils.handlePublicPermissions(docName, 'read'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -113,9 +113,9 @@ tags = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName),
|
||||
apiUtils.handlePermissions(docName, 'add'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName),
|
||||
localUtils.handlePermissions(docName, 'add'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -156,9 +156,9 @@ tags = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.idDefaultOptions}),
|
||||
apiUtils.handlePermissions(docName, 'edit'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: localUtils.idDefaultOptions}),
|
||||
localUtils.handlePermissions(docName, 'edit'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -187,9 +187,9 @@ tags = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.idDefaultOptions}),
|
||||
apiUtils.handlePermissions(docName, 'destroy'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: localUtils.idDefaultOptions}),
|
||||
localUtils.handlePermissions(docName, 'destroy'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
deleteTag
|
||||
];
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var debug = require('ghost-ignition').debug('api:themes'),
|
||||
Promise = require('bluebird'),
|
||||
fs = require('fs-extra'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
common = require('../lib/common'),
|
||||
settingsModel = require('../models/settings').Settings,
|
||||
settingsCache = require('../settings/cache'),
|
||||
|
@ -24,7 +24,7 @@ themes = {
|
|||
* in the PSM to be able to choose a custom post template.
|
||||
*/
|
||||
browse: function browse(options) {
|
||||
return apiUtils
|
||||
return localUtils
|
||||
// Permissions
|
||||
.handlePermissions('themes', 'browse')(options)
|
||||
// Main action
|
||||
|
@ -43,7 +43,7 @@ themes = {
|
|||
loadedTheme,
|
||||
checkedTheme;
|
||||
|
||||
return apiUtils
|
||||
return localUtils
|
||||
// Permissions
|
||||
.handlePermissions('themes', 'activate')(options)
|
||||
// Validation
|
||||
|
@ -94,7 +94,7 @@ themes = {
|
|||
throw new common.errors.ValidationError({message: common.i18n.t('errors.api.themes.overrideCasper')});
|
||||
}
|
||||
|
||||
return apiUtils
|
||||
return localUtils
|
||||
// Permissions
|
||||
.handlePermissions('themes', 'add')(options)
|
||||
// Validation
|
||||
|
@ -168,7 +168,7 @@ themes = {
|
|||
return Promise.reject(new common.errors.BadRequestError({message: common.i18n.t('errors.api.themes.invalidRequest')}));
|
||||
}
|
||||
|
||||
return apiUtils
|
||||
return localUtils
|
||||
// Permissions
|
||||
.handlePermissions('themes', 'read')(options)
|
||||
.then(function sendTheme() {
|
||||
|
@ -187,7 +187,7 @@ themes = {
|
|||
var themeName = options.name,
|
||||
theme;
|
||||
|
||||
return apiUtils
|
||||
return localUtils
|
||||
// Permissions
|
||||
.handlePermissions('themes', 'destroy')(options)
|
||||
// Validation
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
var Promise = require('bluebird'),
|
||||
_ = require('lodash'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
canThis = require('../permissions').canThis,
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
|
@ -26,7 +26,7 @@ users = {
|
|||
*/
|
||||
browse: function browse(options) {
|
||||
var extraOptions = ['status'],
|
||||
permittedOptions = apiUtils.browseDefaultOptions.concat(extraOptions),
|
||||
permittedOptions = localUtils.browseDefaultOptions.concat(extraOptions),
|
||||
tasks;
|
||||
|
||||
/**
|
||||
|
@ -41,9 +41,9 @@ users = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: permittedOptions}),
|
||||
apiUtils.handlePublicPermissions(docName, 'browse'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {opts: permittedOptions}),
|
||||
localUtils.handlePublicPermissions(docName, 'browse'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -88,9 +88,9 @@ users = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {attrs: attrs}),
|
||||
apiUtils.handlePublicPermissions(docName, 'read'),
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.validate(docName, {attrs: attrs}),
|
||||
localUtils.handlePublicPermissions(docName, 'read'),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -106,7 +106,7 @@ users = {
|
|||
*/
|
||||
edit: function edit(object, options) {
|
||||
var extraOptions = ['editRoles'],
|
||||
permittedOptions = extraOptions.concat(apiUtils.idDefaultOptions),
|
||||
permittedOptions = extraOptions.concat(localUtils.idDefaultOptions),
|
||||
tasks;
|
||||
|
||||
if (object.users && object.users[0] && object.users[0].roles && object.users[0].roles[0]) {
|
||||
|
@ -212,9 +212,9 @@ users = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: permittedOptions}),
|
||||
localUtils.validate(docName, {opts: permittedOptions}),
|
||||
handlePermissions,
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -272,9 +272,9 @@ users = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.idDefaultOptions}),
|
||||
localUtils.validate(docName, {opts: localUtils.idDefaultOptions}),
|
||||
handlePermissions,
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
deleteUser
|
||||
];
|
||||
|
||||
|
@ -292,7 +292,7 @@ users = {
|
|||
var tasks;
|
||||
|
||||
function validateRequest() {
|
||||
return apiUtils.validate('password')(object, options)
|
||||
return localUtils.validate('password')(object, options)
|
||||
.then(function (options) {
|
||||
var data = options.data.password[0];
|
||||
|
||||
|
@ -344,7 +344,7 @@ users = {
|
|||
tasks = [
|
||||
validateRequest,
|
||||
handlePermissions,
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -394,9 +394,9 @@ users = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate('owner'),
|
||||
localUtils.validate('owner'),
|
||||
handlePermissions,
|
||||
apiUtils.convertOptions(allowedIncludes),
|
||||
localUtils.convertOptions(allowedIncludes),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ var Promise = require('bluebird'),
|
|||
https = require('https'),
|
||||
url = require('url'),
|
||||
pipeline = require('../utils/pipeline'),
|
||||
apiUtils = require('./utils'),
|
||||
localUtils = require('./utils'),
|
||||
models = require('../models'),
|
||||
common = require('../lib/common'),
|
||||
docName = 'webhooks',
|
||||
|
@ -95,8 +95,8 @@ webhooks = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName),
|
||||
apiUtils.handlePermissions(docName, 'add'),
|
||||
localUtils.validate(docName),
|
||||
localUtils.handlePermissions(docName, 'add'),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
@ -125,8 +125,8 @@ webhooks = {
|
|||
|
||||
// Push all of our tasks into a `tasks` array in the correct order
|
||||
tasks = [
|
||||
apiUtils.validate(docName, {opts: apiUtils.idDefaultOptions}),
|
||||
apiUtils.handlePermissions(docName, 'destroy'),
|
||||
localUtils.validate(docName, {opts: localUtils.idDefaultOptions}),
|
||||
localUtils.handlePermissions(docName, 'destroy'),
|
||||
doQuery
|
||||
];
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue