cont3xt/cont3xt.js
/**
 * PUT - /api/settings
 *
 * Updates the general cont3xt settings
 * @name /settings
 * @param {object} settings - General cont3xt settings for the logged in user
 * @returns {boolean} success - True if the request was successful, false otherwise
 * @returns {string} text - The success/error message to (optionally) display to the user
 */
/api/settings
Updates the general cont3xt settings
@name /settings
@param {object} settings - General cont3xt settings for the logged in user
@returns {boolean} success - True if the request was successful, false otherwise
@returns {string} text - The success/error message to (optionally) display to the user
/ api / settings Updates the general cont3xt settings @name / settings @param { object } settings - General cont3xt settings for the logged in user @returns { boolean } success - True if the request was successful false otherwise @returns { string } text - The success / error message to ( optionally ) display to the user
function apiPutSettings (req, res, next) {
  let save = false;
  User.getUser(req.user.userId, (err, user) => {
    if (err || !user) {
      return res.send({ success: false, text: 'Fetching user issue' });
    }
    if (user.cont3xt === undefined) { user.cont3xt = {}; }
    if (req.body?.settings) {
      user.cont3xt.settings = req.body.settings;
      save = true;
    }
    if (req.body?.linkGroup) {
      user.cont3xt.linkGroup = req.body.linkGroup;
      save = true;
    }
    if (!save) {
      return res.send({ success: false, text: 'Nothing sent to change' });
    }
    user.save((err) => {
      res.send({ success: true, text: 'Saved' });
    });
  });
}
function apiPutSettings ( req , res , next ) { let save = false ; User . getUser ( req . user . userId , ( err , user ) => { if ( err || ! user ) { return res . send ( { success : false , text : 'Fetching user issue' } ) ; } if ( user . cont3xt === undefined ) { user . cont3xt = { } ; } if ( req . body ?. settings ) { user . cont3xt . settings = req . body . settings ; save = true ; } if ( req . body ?. linkGroup ) { user . cont3xt . linkGroup = req . body . linkGroup ; save = true ; } if ( ! save ) { return res . send ( { success : false , text : 'Nothing sent to change' } ) ; } user . save ( ( err ) => { res . send ( { success : true , text : 'Saved' } ) ; } ) ; } ) ; }
PUT - /api/settings
 Updates the general cont3xt settings
 @name /settings
 @param {object} settings - General cont3xt settings for the logged in user
 @returns {boolean} success - True if the request was successful, false otherwise
 @returns {string} text - The success/error message to (optionally) display to the user
PUT - / api / settings Updates the general cont3xt settings @name / settings @param { object } settings - General cont3xt settings for the logged in user @returns { boolean } success - True if the request was successful false otherwise @returns { string } text - The success / error message to ( optionally ) display to the user