From 55a0c69451bbdd1db095f27ba9ea8b572e98e99a Mon Sep 17 00:00:00 2001 From: Thibaut Patel Date: Fri, 21 May 2021 09:55:52 +0200 Subject: [PATCH] Added the customThemes limits to all api versions https://github.com/TryGhost/Team/issues/663 --- core/server/api/v2/themes.js | 10 ++++++++-- core/server/api/v3/themes.js | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/server/api/v2/themes.js b/core/server/api/v2/themes.js index 4fe2d8d0bf..1034e897e3 100644 --- a/core/server/api/v2/themes.js +++ b/core/server/api/v2/themes.js @@ -28,8 +28,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 @@ -54,7 +59,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 diff --git a/core/server/api/v3/themes.js b/core/server/api/v3/themes.js index 35346ff5b7..ab1af77bac 100644 --- a/core/server/api/v3/themes.js +++ b/core/server/api/v3/themes.js @@ -28,8 +28,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 @@ -54,7 +59,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