diff --git a/README.md b/README.md index ee283fb7de..946ebb1cb2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ NodeBB by itself contains a "common core" of basic functionality, while addition ### [Try it now](//try.nodebb.org) | [Documentation](//docs.nodebb.org) -<<<<<<< HEAD + ### Team Members + Abdallah Almana aalmana@andrew.cmu.edu + Abdulwahab Al-Rumaihi arumaihi@andrew.cmu.edu @@ -18,8 +18,7 @@ NodeBB by itself contains a "common core" of basic functionality, while addition + Najoud Al-Talib ntalib@andrew.cmu.edu + Reem Kensouh rkensouh@andrew.cmu.edu -======= ->>>>>>> individual-fork/f24 + ## Screenshots NodeBB's theming engine is highly flexible and does not restrict your design choices. Check out some themed installs in these screenshots below: diff --git a/src/meta/configs.js b/src/meta/configs.js index 80159490c4..ae38be36f8 100644 --- a/src/meta/configs.js +++ b/src/meta/configs.js @@ -1,4 +1,3 @@ - 'use strict'; const nconf = require('nconf'); @@ -18,41 +17,67 @@ Meta.config = {}; // called after data is loaded from db function deserialize(config) { const deserialized = {}; + Object.keys(config).forEach((key) => { const defaultType = typeof defaults[key]; const type = typeof config[key]; const number = parseFloat(config[key]); - if (defaultType === 'string' && type === 'number') { - deserialized[key] = String(config[key]); - } else if (defaultType === 'number' && type === 'string') { - if (!isNaN(number) && isFinite(config[key])) { - deserialized[key] = number; - } else { - deserialized[key] = defaults[key]; - } - } else if (config[key] === 'true') { - deserialized[key] = true; - } else if (config[key] === 'false') { - deserialized[key] = false; - } else if (config[key] === null) { - deserialized[key] = defaults[key]; - } else if (defaultType === 'undefined' && !isNaN(number) && isFinite(config[key])) { - deserialized[key] = number; - } else if (Array.isArray(defaults[key]) && !Array.isArray(config[key])) { - try { - deserialized[key] = JSON.parse(config[key] || '[]'); - } catch (err) { - winston.error(err.stack); - deserialized[key] = defaults[key]; - } - } else { - deserialized[key] = config[key]; - } + deserialized[key] = handleTypeConversion(defaultType, type, config[key], number, key); }); + return deserialized; } +// Function to handle type conversion during deserialization +function handleTypeConversion(defaultType, type, value, number, key) { + if (defaultType === 'string' && type === 'number') { + return String(value); + } + + if (defaultType === 'number' && type === 'string') { + return handleNumberConversion(number, value, key); + } + + if (value === 'true') { + return true; + } + + if (value === 'false') { + return false; + } + + if (value === null) { + return defaults[key]; + } + + if (defaultType === 'undefined' && !isNaN(number) && isFinite(value)) { + return number; + } + + if (Array.isArray(defaults[key]) && !Array.isArray(value)) { + return handleArrayConversion(value, key); + } + + return value; +} + +function handleNumberConversion(number, value, key) { + if (!isNaN(number) && isFinite(value)) { + return number; + } + return defaults[key]; +} + +function handleArrayConversion(value, key) { + try { + return JSON.parse(value || '[]'); + } catch (err) { + winston.error(err.stack); + return defaults[key]; + } +} + // called before data is saved to db function serialize(config) { const serialized = {}; @@ -213,7 +238,6 @@ async function getLogoSize(data) { size = await image.size(path.join(nconf.get('upload_path'), 'system', 'site-logo-x50.png')); } catch (err) { if (err.code === 'ENOENT') { - // For whatever reason the x50 logo wasn't generated, gracefully error out winston.warn('[logo] The email-safe logo doesn\'t seem to have been created, please re-upload your site logo.'); size = { height: 0, diff --git a/src/user/create.js b/src/user/create.js index 610d614e81..70263f8704 100644 --- a/src/user/create.js +++ b/src/user/create.js @@ -122,6 +122,7 @@ module.exports = function (User) { return userData.uid; } + async function storePassword(uid, password) { if (!password) { return;