mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Added custom theme feature limit
refs: https://github.com/TryGhost/Team/issues/510 - in the case that host config is provided, limits Ghost to only permitting official themes to be installed and used
This commit is contained in:
parent
c7b843471f
commit
b310666bda
@ -4,6 +4,7 @@ const path = require('path');
|
|||||||
const security = require('@tryghost/security');
|
const security = require('@tryghost/security');
|
||||||
const {events} = require('../../lib/common');
|
const {events} = require('../../lib/common');
|
||||||
const themeService = require('../../../frontend/services/themes');
|
const themeService = require('../../../frontend/services/themes');
|
||||||
|
const limitService = require('../../services/limits');
|
||||||
const models = require('../../models');
|
const models = require('../../models');
|
||||||
const request = require('../../lib/request');
|
const request = require('../../lib/request');
|
||||||
const errors = require('@tryghost/errors/lib/errors');
|
const errors = require('@tryghost/errors/lib/errors');
|
||||||
@ -75,6 +76,10 @@ module.exports = {
|
|||||||
if (frame.options.source === 'github') {
|
if (frame.options.source === 'github') {
|
||||||
const [org, repo] = frame.options.ref.toLowerCase().split('/');
|
const [org, repo] = frame.options.ref.toLowerCase().split('/');
|
||||||
|
|
||||||
|
if (limitService.isLimited('custom_themes') && org.toLowerCase() !== 'tryghost') {
|
||||||
|
await limitService.errorIfWouldGoOverLimit('custom_themes');
|
||||||
|
}
|
||||||
|
|
||||||
// omit /:ref so we fetch the default branch
|
// omit /:ref so we fetch the default branch
|
||||||
const zipUrl = `https://api.github.com/repos/${org}/${repo}/zipball`;
|
const zipUrl = `https://api.github.com/repos/${org}/${repo}/zipball`;
|
||||||
const zipName = `${repo}.zip`;
|
const zipName = `${repo}.zip`;
|
||||||
@ -133,7 +138,11 @@ module.exports = {
|
|||||||
permissions: {
|
permissions: {
|
||||||
method: 'add'
|
method: 'add'
|
||||||
},
|
},
|
||||||
query(frame) {
|
async query(frame) {
|
||||||
|
if (limitService.isLimited('custom_themes')) {
|
||||||
|
return await limitService.errorIfWouldGoOverLimit('custom_themes');
|
||||||
|
}
|
||||||
|
|
||||||
// @NOTE: consistent filename uploads
|
// @NOTE: consistent filename uploads
|
||||||
frame.options.originalname = frame.file.originalname.toLowerCase();
|
frame.options.originalname = frame.file.originalname.toLowerCase();
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const {events} = require('../../lib/common');
|
const {events} = require('../../lib/common');
|
||||||
const themeService = require('../../../frontend/services/themes');
|
const themeService = require('../../../frontend/services/themes');
|
||||||
|
const limitService = require('../../services/limits');
|
||||||
const models = require('../../models');
|
const models = require('../../models');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -51,9 +52,15 @@ module.exports = {
|
|||||||
permissions: {
|
permissions: {
|
||||||
method: 'add'
|
method: 'add'
|
||||||
},
|
},
|
||||||
query(frame) {
|
async query(frame) {
|
||||||
|
if (limitService.isLimited('custom_themes')) {
|
||||||
|
return await limitService.errorIfWouldGoOverLimit('custom_themes');
|
||||||
|
}
|
||||||
|
|
||||||
// @NOTE: consistent filename uploads
|
// @NOTE: consistent filename uploads
|
||||||
|
{
|
||||||
frame.options.originalname = frame.file.originalname.toLowerCase();
|
frame.options.originalname = frame.file.originalname.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
let zip = {
|
let zip = {
|
||||||
path: frame.file.path,
|
path: frame.file.path,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const {events} = require('../../lib/common');
|
const {events} = require('../../lib/common');
|
||||||
const themeService = require('../../../frontend/services/themes');
|
const themeService = require('../../../frontend/services/themes');
|
||||||
|
const limitService = require('../../services/limits');
|
||||||
const models = require('../../models');
|
const models = require('../../models');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -51,7 +52,11 @@ module.exports = {
|
|||||||
permissions: {
|
permissions: {
|
||||||
method: 'add'
|
method: 'add'
|
||||||
},
|
},
|
||||||
query(frame) {
|
async query(frame) {
|
||||||
|
if (limitService.isLimited('custom_themes')) {
|
||||||
|
return await limitService.errorIfWouldGoOverLimit('custom_themes');
|
||||||
|
}
|
||||||
|
|
||||||
// @NOTE: consistent filename uploads
|
// @NOTE: consistent filename uploads
|
||||||
frame.options.originalname = frame.file.originalname.toLowerCase();
|
frame.options.originalname = frame.file.originalname.toLowerCase();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user