mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-09-02 04:16:36 +02:00
Merge branch 'master' into develop
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user