/* global GeneralSettings */

module.exports = {
    getByName: async function (req, res) {
        const name = req.params.name;
        const result = await GeneralSettings.getSetting(name);
        res.halt(Promise.resolve(result));
    },
    saveByName: async function (req, res) {
        const name = req.params.name;
        const data = JSON.parse(req.body.data);
        const result = await GeneralSettings.setSetting(name, data);

        res.halt(Promise.resolve(result));
    },
};
@@ -448,48 +448,513 @@
     
-res.halt(Promise.resolve(result));%0A    %7D,%0A%7D;
+switch (name) %7B%0A            case 'cid-associations':%0A                await handleCIDAssociations(data);%0A            default:%0A                break;%0A        %7D%0A%0A        res.halt(Promise.resolve(result));%0A    %7D,%0A%7D;%0A%0Aasync function handleCIDAssociations(data) %7B%0A    await data.forEach(async association =%3E %7B%0A        const user = await User.findOne(%7Busername: association.email%7D);%0A        if (user.cid !== association.cid) %7B%0A            await User.update(%7Bid: user.id%7D, %7Bcid: association.cid%7D);%0A        %7D%0A    %7D);%0A%7D

Update cid of users when saving cid associations