Use BAD_STATE consistently for demo mode

This commit is contained in:
Girish Ramakrishnan
2024-01-13 21:15:41 +01:00
parent a007a8e40c
commit 46a589f794
6 changed files with 13 additions and 13 deletions

View File

@@ -93,7 +93,7 @@ async function setBlocklist(blocklist, auditSource) {
}
if (count >= 262144) throw new BoxError(BoxError.CONFLICT, 'Blocklist is too large. Max 262144 entries are allowed'); // see the cloudron-firewall.sh
if (constants.DEMO) throw new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode');
if (constants.DEMO) throw new BoxError(BoxError.BAD_STATE, 'Not allowed in demo mode');
// store in blob since the value field is TEXT and has 16kb size limit
await settings.setBlob(settings.FIREWALL_BLOCKLIST_KEY, Buffer.from(blocklist));
@@ -125,7 +125,7 @@ async function getIPv4Config() {
async function setIPv4Config(ipv4Config) {
assert.strictEqual(typeof ipv4Config, 'object');
if (constants.DEMO) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
if (constants.DEMO) throw new BoxError(BoxError.BAD_STATE, 'Not allowed in demo mode');
const error = await testIPv4Config(ipv4Config);
if (error) throw error;
@@ -141,7 +141,7 @@ async function getIPv6Config() {
async function setIPv6Config(ipv6Config) {
assert.strictEqual(typeof ipv6Config, 'object');
if (constants.DEMO) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
if (constants.DEMO) throw new BoxError(BoxError.BAD_STATE, 'Not allowed in demo mode');
const error = await testIPv6Config(ipv6Config);
if (error) throw error;