fix: prevent crash if groups is not valid json

isekai-main
Barış Soner Uşaklı 3 years ago
parent 968d461692
commit cc0a087a70

@ -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')) {
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)) {

Loading…
Cancel
Save