mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 13:36:07 +02:00
Merge branch 'master' into develop
This commit is contained in:
@@ -402,10 +402,10 @@ async function getTooltipData(uids) {
|
||||
uids = uids.slice(0, cutoff - 1);
|
||||
}
|
||||
|
||||
const usernames = await user.getUsernamesByUids(uids);
|
||||
const users = await user.getUsersFields(uids, ['username']);
|
||||
return {
|
||||
otherCount,
|
||||
usernames,
|
||||
usernames: users.map(user => user.displayname),
|
||||
cutoff,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -87,7 +87,8 @@ program
|
||||
.option('--log-level <level>', 'Default logging level to use', 'info')
|
||||
.option('--config <value>', 'Specify a config file', 'config.json')
|
||||
.option('-d, --dev', 'Development mode, including verbose logging', false)
|
||||
.option('-l, --log', 'Log subprocess output to console', false);
|
||||
.option('-l, --log', 'Log subprocess output to console', false)
|
||||
.option('-y, --unattended', 'Answer yes to any prompts, like plugin upgrades', false);
|
||||
|
||||
// provide a yargs object ourselves
|
||||
// otherwise yargs will consume `--help` or `help`
|
||||
@@ -294,6 +295,7 @@ program
|
||||
].join('\n')}`);
|
||||
})
|
||||
.action((scripts, options) => {
|
||||
options.unattended = program.opts().unattended;
|
||||
if (program.opts().dev) {
|
||||
process.env.NODE_ENV = 'development';
|
||||
global.env = 'development';
|
||||
@@ -308,7 +310,8 @@ program
|
||||
.alias('upgradePlugins')
|
||||
.description('Upgrade plugins')
|
||||
.action(() => {
|
||||
require('./upgrade-plugins').upgradePlugins((err) => {
|
||||
const { unattended } = program.opts();
|
||||
require('./upgrade-plugins').upgradePlugins(unattended, (err) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ async function checkPlugins() {
|
||||
return upgradable;
|
||||
}
|
||||
|
||||
async function upgradePlugins() {
|
||||
async function upgradePlugins(unattended = false) {
|
||||
try {
|
||||
const found = await checkPlugins();
|
||||
if (found && found.length) {
|
||||
@@ -132,16 +132,18 @@ async function upgradePlugins() {
|
||||
console.log(chalk.green('\nAll packages up-to-date!'));
|
||||
return;
|
||||
}
|
||||
let result = { upgrade: 'y' };
|
||||
if (!unattended) {
|
||||
prompt.message = '';
|
||||
prompt.delimiter = '';
|
||||
|
||||
prompt.message = '';
|
||||
prompt.delimiter = '';
|
||||
|
||||
prompt.start();
|
||||
const result = await prompt.get({
|
||||
name: 'upgrade',
|
||||
description: '\nProceed with upgrade (y|n)?',
|
||||
type: 'string',
|
||||
});
|
||||
prompt.start();
|
||||
result = await prompt.get({
|
||||
name: 'upgrade',
|
||||
description: '\nProceed with upgrade (y|n)?',
|
||||
type: 'string',
|
||||
});
|
||||
}
|
||||
|
||||
if (['y', 'Y', 'yes', 'YES'].includes(result.upgrade)) {
|
||||
console.log('\nUpgrading packages...');
|
||||
|
||||
@@ -24,9 +24,9 @@ const steps = {
|
||||
},
|
||||
plugins: {
|
||||
message: 'Checking installed plugins for updates...',
|
||||
handler: async function () {
|
||||
handler: async function (options) {
|
||||
await require('../database').init();
|
||||
await upgradePlugins();
|
||||
await upgradePlugins(options.unattended);
|
||||
},
|
||||
},
|
||||
schema: {
|
||||
@@ -45,14 +45,14 @@ const steps = {
|
||||
},
|
||||
};
|
||||
|
||||
async function runSteps(tasks) {
|
||||
async function runSteps(tasks, options) {
|
||||
try {
|
||||
for (let i = 0; i < tasks.length; i++) {
|
||||
const step = steps[tasks[i]];
|
||||
if (step && step.message && step.handler) {
|
||||
process.stdout.write(`\n${chalk.bold(`${i + 1}. `)}${chalk.yellow(step.message)}`);
|
||||
/* eslint-disable-next-line */
|
||||
await step.handler();
|
||||
await step.handler(options);
|
||||
}
|
||||
}
|
||||
const message = 'NodeBB Upgrade Complete!';
|
||||
@@ -95,7 +95,7 @@ async function runUpgrade(upgrades, options) {
|
||||
options.plugins || options.schema || options.build) {
|
||||
tasks = tasks.filter(key => options[key]);
|
||||
}
|
||||
await runSteps(tasks);
|
||||
await runSteps(tasks, options);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ helpers.getCustomUserFields = async function (callerUID, userData) {
|
||||
if (f.type === 'input-link' && userValue) {
|
||||
f.linkValue = validator.escape(String(userValue.replace('http://', '').replace('https://', '')));
|
||||
}
|
||||
f['select-options'] = f['select-options'].split('\n').filter(Boolean).map(
|
||||
f['select-options'] = (f['select-options'] || '').split('\n').filter(Boolean).map(
|
||||
opt => ({
|
||||
value: opt,
|
||||
selected: Array.isArray(userValue) ?
|
||||
|
||||
@@ -113,8 +113,14 @@ const doUnsubscribe = async (payload) => {
|
||||
user.updateDigestSetting(payload.uid, 'off'),
|
||||
]);
|
||||
} else if (payload.template === 'notification') {
|
||||
const currentToNewSetting = {
|
||||
notificationemail: 'notification',
|
||||
email: 'none',
|
||||
};
|
||||
const current = await db.getObjectField(`user:${payload.uid}:settings`, `notificationType_${payload.type}`);
|
||||
await user.setSetting(payload.uid, `notificationType_${payload.type}`, (current === 'notificationemail' ? 'notification' : 'none'));
|
||||
if (currentToNewSetting.hasOwnProperty(current)) {
|
||||
await user.setSetting(payload.uid, `notificationType_${payload.type}`, currentToNewSetting[current]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -49,7 +49,10 @@ async function registerAndLoginUser(req, res, userData) {
|
||||
|
||||
const uid = await user.create(userData);
|
||||
if (res.locals.processLogin) {
|
||||
await authenticationController.doLogin(req, uid);
|
||||
const hasLoginPrivilege = await privileges.global.can('local:login', uid);
|
||||
if (hasLoginPrivilege) {
|
||||
await authenticationController.doLogin(req, uid);
|
||||
}
|
||||
}
|
||||
|
||||
// Distinguish registrations through invites from direct ones
|
||||
|
||||
@@ -6,7 +6,7 @@ const validator = require('validator');
|
||||
const meta = require('../meta');
|
||||
const user = require('../user');
|
||||
const plugins = require('../plugins');
|
||||
const privileges = require('../privileges');
|
||||
const privilegesHelpers = require('../privileges/helpers');
|
||||
const helpers = require('./helpers');
|
||||
|
||||
const Controllers = module.exports;
|
||||
@@ -126,7 +126,8 @@ Controllers.login = async function (req, res) {
|
||||
data.title = '[[pages:login]]';
|
||||
data.allowPasswordReset = !meta.config['password:disableEdit'];
|
||||
|
||||
const hasLoginPrivilege = await privileges.global.canGroup('local:login', 'registered-users');
|
||||
const loginPrivileges = await privilegesHelpers.getGroupPrivileges(0, ['groups:local:login']);
|
||||
const hasLoginPrivilege = !!loginPrivileges.find(privilege => privilege.privileges['groups:local:login']);
|
||||
data.allowLocalLogin = hasLoginPrivilege || parseInt(req.query.local, 10) === 1;
|
||||
|
||||
if (!data.allowLocalLogin && !data.allowRegistration && data.alternate_logins && data.authentication.length === 1) {
|
||||
|
||||
@@ -164,7 +164,10 @@ actions.buildCSS = async function buildCSS(data) {
|
||||
loadPaths: data.paths,
|
||||
};
|
||||
if (data.minify) {
|
||||
opts.silenceDeprecations = ['mixed-decls', 'color-functions'];
|
||||
opts.silenceDeprecations = [
|
||||
'legacy-js-api', 'mixed-decls', 'color-functions',
|
||||
'global-builtin', 'import',
|
||||
];
|
||||
}
|
||||
const scssOutput = await sass.compileStringAsync(data.source, opts);
|
||||
css = scssOutput.css.toString();
|
||||
|
||||
@@ -17,7 +17,7 @@ const tx = require('../translator');
|
||||
module.exports = function (User) {
|
||||
User.updateProfile = async function (uid, data, extraFields) {
|
||||
let fields = [
|
||||
'username', 'email', 'fullname', 'website', 'location',
|
||||
'username', 'email', 'fullname',
|
||||
'groupTitle', 'birthday', 'signature', 'aboutme',
|
||||
...await db.getSortedSetRange('user-custom-fields', 0, -1),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user