0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Added configurable limits to the theme management

issue https://github.com/TryGhost/Team/issues/590
This commit is contained in:
Thibaut Patel 2021-04-09 18:30:17 +02:00
parent b10cc5f62d
commit 44244871fe

View file

@ -35,8 +35,13 @@ module.exports = {
}
},
permissions: true,
query(frame) {
async query(frame) {
let themeName = frame.options.name;
if (limitService.isLimited('customThemes')) {
await limitService.errorIfWouldGoOverLimit('customThemes', {value: themeName});
}
const newSettings = [{
key: 'active_theme',
value: themeName
@ -76,8 +81,9 @@ module.exports = {
if (frame.options.source === 'github') {
const [org, repo] = frame.options.ref.toLowerCase().split('/');
//TODO: move the organization check to config
if (limitService.isLimited('customThemes') && org.toLowerCase() !== 'tryghost') {
await limitService.errorIfWouldGoOverLimit('customThemes');
await limitService.errorIfWouldGoOverLimit('customThemes', {value: repo.toLowerCase()});
}
// omit /:ref so we fetch the default branch
@ -140,7 +146,8 @@ module.exports = {
},
async query(frame) {
if (limitService.isLimited('customThemes')) {
await limitService.errorIfWouldGoOverLimit('customThemes');
// Sending a bad string to make sure it fails (empty string isn't valid)
await limitService.errorIfWouldGoOverLimit('customThemes', {value: '.'});
}
// @NOTE: consistent filename uploads