mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: prevent crash if groups is not valid json
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const validator = require('validator');
|
||||
const winston = require('winston');
|
||||
|
||||
const plugins = require('../plugins');
|
||||
const db = require('../database');
|
||||
@@ -66,7 +67,12 @@ admin.get = async function () {
|
||||
const data = await db.getObjects(ids.map(id => `navigation:enabled:${id}`));
|
||||
cache = data.map((item) => {
|
||||
if (item.hasOwnProperty('groups')) {
|
||||
item.groups = JSON.parse(item.groups);
|
||||
try {
|
||||
item.groups = JSON.parse(item.groups);
|
||||
} catch (err) {
|
||||
winston.error(err.stack);
|
||||
item.groups = [];
|
||||
}
|
||||
}
|
||||
item.groups = item.groups || [];
|
||||
if (item.groups && !Array.isArray(item.groups)) {
|
||||
|
||||
Reference in New Issue
Block a user