Merge remote-tracking branch 'upstream/master'

v1.18.x
akhoury 9 years ago
commit 7f0c46b3a7

@ -28,6 +28,6 @@
"maximumCoverImageSize": 2048,
"profileImageDimension": 128,
"requireEmailConfirmation": 0,
"profile:allowProfileImageUploads": 1,
"allowProfileImageUploads": 1,
"teaserPost": "last"
}

@ -53,8 +53,8 @@
"nodebb-plugin-spam-be-gone": "0.4.5",
"nodebb-rewards-essentials": "0.0.6",
"nodebb-theme-lavender": "3.0.6",
"nodebb-theme-persona": "4.0.69",
"nodebb-theme-vanilla": "5.0.41",
"nodebb-theme-persona": "4.0.70",
"nodebb-theme-vanilla": "5.0.42",
"nodebb-widget-essentials": "2.0.5",
"nodemailer": "2.0.0",
"nodemailer-sendmail-transport": "1.0.0",
@ -79,7 +79,7 @@
"uglify-js": "^2.6.0",
"underscore": "~1.8.3",
"underscore.deep": "^0.5.1",
"validator": "^4.0.5",
"validator": "^4.7.1",
"winston": "^2.1.0",
"xregexp": "~3.0.0"
},

@ -17,5 +17,6 @@
"unread_topics": "Unread Topics",
"categories": "Categories",
"tags": "Tags",
"map": "Map"
"map": "Map",
"no-users-found": "No users found!"
}

@ -276,7 +276,11 @@ app.cacheBuster = null;
if (err) {
return app.alertError(err.message);
}
app.openChat(roomId);
if (!ajaxify.currentPage.startsWith('chats/')) {
app.openChat(roomId);
} else {
ajaxify.go('chats/' + roomId);
}
});
};

@ -80,7 +80,8 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
}
templates.parse('partials/modals/change_picture_modal', {
pictures: pictures,
uploaded: !!ajaxify.data.uploadedpicture
uploaded: !!ajaxify.data.uploadedpicture,
allowProfileImageUploads: ajaxify.data.allowProfileImageUploads
}, function(html) {
translator.translate(html, function(html) {
var modal = bootbox.dialog({
@ -201,7 +202,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
modal.find('[data-action="upload"]').on('click', function() {
modal.modal('hide');
uploader.open(config.relative_path + '/api/user/' + ajaxify.data.userslug + '/uploadpicture', {}, config.maximumProfileImageSize, function(imageUrlOnServer) {
uploader.open(config.relative_path + '/api/user/' + ajaxify.data.userslug + '/uploadpicture', {}, ajaxify.data.maximumProfileImageSize, function(imageUrlOnServer) {
onUploadComplete(imageUrlOnServer);
});
@ -274,19 +275,19 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
function updateSignature() {
var el = $('#inputSignature');
$('#signatureCharCountLeft').html(getCharsLeft(el, config.maximumSignatureLength));
$('#signatureCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumSignatureLength));
el.on('keyup change', function() {
$('#signatureCharCountLeft').html(getCharsLeft(el, config.maximumSignatureLength));
$('#signatureCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumSignatureLength));
});
}
function updateAboutMe() {
var el = $('#inputAboutMe');
$('#aboutMeCharCountLeft').html(getCharsLeft(el, config.maximumAboutMeLength));
$('#aboutMeCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumAboutMeLength));
el.on('keyup change', function() {
$('#aboutMeCharCountLeft').html(getCharsLeft(el, config.maximumAboutMeLength));
$('#aboutMeCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumAboutMeLength));
});
}

@ -1,6 +1,6 @@
'use strict';
/* globals define, ajaxify, socket, app, config, utils */
/* globals define, ajaxify, socket, app, utils */
define('forum/account/edit/password', ['forum/account/header', 'translator'], function(header, translator) {
var AccountEditPassword = {};
@ -21,7 +21,7 @@ define('forum/account/edit/password', ['forum/account/header', 'translator'], fu
var passwordsmatch = false;
function onPasswordChanged() {
if (password.val().length < config.minimumPasswordLength) {
if (password.val().length < ajaxify.data.minimumPasswordLength) {
showError(password_notify, '[[user:change_password_error_length]]');
passwordvalid = false;
} else if (!utils.isPasswordValid(password.val())) {

@ -29,6 +29,8 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
Chats.scrollToBottom($('.expanded-chat ul'));
Chats.initialised = true;
Chats.handleSearch();
if (ajaxify.data.hasOwnProperty('roomId')) {
components.get('chat/input').focus();
@ -426,10 +428,10 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
};
Chats.sendMessage = function(roomId, inputEl) {
var msg = inputEl.val(),
mid = inputEl.attr('data-mid');
var msg = inputEl.val();
var mid = inputEl.attr('data-mid');
if (msg.length > config.maximumChatMessageLength) {
if (msg.length > ajaxify.data.maximumChatMessageLength) {
return app.alertError('[[error:chat-message-too-long]]');
}
@ -530,6 +532,71 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
callback();
});
}
Chats.handleSearch = function() {
var timeoutId = 0;
components.get('chat/search').on('keyup', function() {
if (timeoutId) {
clearTimeout(timeoutId);
timeoutId = 0;
}
timeoutId = setTimeout(doSearch, 250);
});
function doSearch() {
var username = components.get('chat/search').val();
var chatsListEl = $('[component="chat/search/list"]');
if (!username) {
return chatsListEl.empty();
}
socket.emit('user.search', {
query: username,
searchBy: 'username'
}, function(err, data) {
if (err) {
return app.alertError(err.message);
}
chatsListEl.empty();
if (data.users.length === 0) {
chatsListEl.translateHtml('<li><div><span>[[users:no-users-found]]</span></div></li>');
} else {
data.users.forEach(function(userObj) {
function createUserImage() {
return (userObj.picture ?
'<img src="' + userObj.picture + '" title="' + userObj.username +'" />' :
'<div class="user-icon" style="background-color: ' + userObj['icon:bgColor'] + '">' + userObj['icon:text'] + '</div>') +
'<i class="fa fa-circle status ' + userObj.status + '"></i> ' + userObj.username;
}
var chatEl = $('<li component="chat/search/user" />')
.attr('data-uid', userObj.uid)
.appendTo(chatsListEl);
chatEl.append(createUserImage());
chatEl.click(function() {
socket.emit('modules.chats.hasPrivateChat', userObj.uid, function(err, roomId) {
if (err) {
return app.alertError(err.message);
}
if (roomId) {
ajaxify.go('chats/' + roomId);
} else {
app.newChat(userObj.uid);
}
});
});
});
}
});
}
};
return Chats;
});

@ -10,13 +10,13 @@ define('forum/footer', ['notifications', 'chat', 'components', 'translator'], fu
function updateUnreadTopicCount(count) {
$('#unread-count i')
.toggleClass('unread-count', count > 0)
.attr('data-content', count > 20 ? '20+' : count);
.attr('data-content', count > 99 ? '99+' : count);
}
function updateUnreadChatCount(count) {
components.get('chat/icon')
.toggleClass('unread-count', count > 0)
.attr('data-content', count > 20 ? '20+' : count);
.attr('data-content', count > 99 ? '99+' : count);
}
function initUnreadTopics() {

@ -150,9 +150,9 @@ define('forum/register', ['csrf', 'translator'], function(csrf, translator) {
var username_notify = $('#username-notify');
if (username.length < config.minimumUsernameLength) {
if (username.length < ajaxify.data.minimumUsernameLength) {
showError(username_notify, '[[error:username-too-short]]');
} else if (username.length > config.maximumUsernameLength) {
} else if (username.length > ajaxify.data.maximumUsernameLength) {
showError(username_notify, '[[error:username-too-long]]');
} else if (!utils.isUserNameValid(username) || !utils.slugify(username)) {
showError(username_notify, '[[error:invalid-username]]');
@ -179,7 +179,7 @@ define('forum/register', ['csrf', 'translator'], function(csrf, translator) {
var password_notify = $('#password-notify'),
password_confirm_notify = $('#password-confirm-notify');
if (password.length < config.minimumPasswordLength) {
if (password.length < ajaxify.data.minimumPasswordLength) {
showError(password_notify, '[[user:change_password_error_length]]');
} else if (!utils.isPasswordValid(password)) {
showError(password_notify, '[[user:change_password_error]]');

@ -1,5 +1,5 @@
"use strict";
/*globals define, app, ajaxify, socket, RELATIVE_PATH*/
/*globals define, app, ajaxify, socket, config*/
define('forum/reset_code', function() {
var ResetCode = {};
@ -7,13 +7,12 @@ define('forum/reset_code', function() {
ResetCode.init = function() {
var reset_code = ajaxify.data.code;
var resetEl = $('#reset'),
password = $('#password'),
repeat = $('#repeat'),
noticeEl = $('#notice');
var resetEl = $('#reset');
var password = $('#password');
var repeat = $('#repeat');
resetEl.on('click', function() {
if (password.val().length < config.minimumPasswordLength) {
if (password.val().length < ajaxify.data.minimumPasswordLength) {
app.alertError('[[reset_password:password_too_short]]');
} else if (password.val() !== repeat.val()) {
app.alertError('[[reset_password:passwords_do_not_match]]');
@ -28,7 +27,7 @@ define('forum/reset_code', function() {
return app.alertError(err.message);
}
window.location.href = RELATIVE_PATH + '/login';
window.location.href = config.relative_path + '/login';
});
}
return false;

@ -420,7 +420,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
}
function showStaleWarning(callback) {
if (ajaxify.data.lastposttime < (Date.now() - (1000*60*60*24*config.topicStaleDays))) {
if (ajaxify.data.lastposttime < (Date.now() - (1000 * 60 * 60 * 24 * ajaxify.data.topicStaleDays))) {
translator.translate('[[topic:stale.warning]]', function(translated) {
var warning = bootbox.dialog({
title: '[[topic:stale.title]]',

@ -24,11 +24,11 @@
}
}
if (item.route.match('/users') && data.config.privateUserInfo && !data.config.loggedIn) {
if (item.route.match('/users') && data.privateUserInfo && !data.config.loggedIn) {
return false;
}
if (item.route.match('/tags') && data.config.privateTagListing && !data.config.loggedIn) {
if (item.route.match('/tags') && data.privateTagListing && !data.config.loggedIn) {
return false;
}

@ -139,7 +139,7 @@ define('notifications', ['sounds', 'translator', 'components'], function(sound,
}
notifIcon.toggleClass('unread-count', count > 0);
notifIcon.attr('data-content', count > 20 ? '20+' : count);
notifIcon.attr('data-content', count > 99 ? '99+' : count);
var payload = {
count: count,

@ -1,24 +1,24 @@
'use strict';
var async = require('async'),
posts = require('../posts'),
db = require('../database');
var async = require('async');
var posts = require('../posts');
var db = require('../database');
module.exports = function(Categories) {
Categories.getActiveUsers = function(cid, callback) {
async.waterfall([
function(next) {
function (next) {
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, 24, next);
},
function(pids, next) {
function (pids, next) {
posts.getPostsFields(pids, ['uid'], next);
},
function(posts, next) {
function (posts, next) {
var uids = posts.map(function(post) {
return post.uid;
}).filter(function(uid, index, array) {
return parseInt(uid, 10) !== 0 && array.indexOf(uid) === index;
return parseInt(uid, 10) && array.indexOf(uid) === index;
});
next(null, uids);

@ -42,7 +42,7 @@ module.exports = function(Categories) {
return;
}
category.name = validator.escape(category.name);
category.name = validator.escape(category.name || '');
category.disabled = category.hasOwnProperty('disabled') ? parseInt(category.disabled, 10) === 1 : undefined;
category.icon = category.icon || 'hidden';
if (category.hasOwnProperty('post_count')) {

@ -66,6 +66,7 @@ chatsController.get = function(req, res, callback) {
room.title = room.roomName;
room.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[pages:chats]]', url: '/chats'}, {text: room.roomName}]);
room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
room.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2;
res.render('chats', room);

@ -7,6 +7,7 @@ var winston = require('winston');
var db = require('../../database');
var user = require('../../user');
var meta = require('../../meta');
var helpers = require('../helpers');
var accountHelpers = require('./helpers');
@ -18,6 +19,12 @@ editController.get = function(req, res, callback) {
return callback(err);
}
userData.maximumSignatureLength = parseInt(meta.config.maximumSignatureLength, 10) || 255;
userData.maximumAboutMeLength = parseInt(meta.config.maximumAboutMeLength, 10) || 1000;
userData.maximumProfileImageSize = parseInt(meta.config.maximumProfileImageSize, 10);
userData.allowProfileImageUploads = parseInt(meta.config.allowProfileImageUploads) === 1;
userData.allowAccountDelete = parseInt(meta.config.allowAccountDelete, 10) === 1;
userData.title = '[[pages:account/edit, ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:edit]]'}]);
@ -46,6 +53,10 @@ function renderRoute(name, req, res, next) {
return next();
}
if (name === 'password') {
userData.minimumPasswordLength = parseInt(meta.config.minimumPasswordLength, 10);
}
userData.title = '[[pages:account/edit/' + name + ', ' + userData.username + ']]';
userData.breadcrumbs = helpers.buildBreadcrumbs([
{text: userData.username, url: '/user/' + userData.userslug},

@ -92,17 +92,17 @@ helpers.getUserDataByUserSlug = function(userslug, callerUID, callback) {
userData.sso = results.sso.associations;
userData.status = user.getStatus(userData);
userData.banned = parseInt(userData.banned, 10) === 1;
userData.website = validator.escape(userData.website);
userData.website = validator.escape(userData.website || '');
userData.websiteLink = !userData.website.startsWith('http') ? 'http://' + userData.website : userData.website;
userData.websiteName = userData.website.replace(validator.escape('http://'), '').replace(validator.escape('https://'), '');
userData.followingCount = parseInt(userData.followingCount, 10) || 0;
userData.followerCount = parseInt(userData.followerCount, 10) || 0;
userData.username = validator.escape(userData.username);
userData.email = validator.escape(userData.email);
userData.fullname = validator.escape(userData.fullname);
userData.location = validator.escape(userData.location);
userData.signature = validator.escape(userData.signature);
userData.username = validator.escape(userData.username || '');
userData.email = validator.escape(userData.email || '');
userData.fullname = validator.escape(userData.fullname || '');
userData.location = validator.escape(userData.location || '');
userData.signature = validator.escape(userData.signature || '');
userData.aboutme = validator.escape(userData.aboutme || '');
userData['cover:url'] = userData['cover:url'] || require('../../coverPhoto').getDefaultProfileCover(userData.uid);

@ -28,48 +28,35 @@ apiController.getConfig = function(req, res, next) {
}
var config = {};
config.environment = process.env.NODE_ENV;
config.relative_path = nconf.get('relative_path');
config.socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket'];
config.websocketAddress = nconf.get('socket.io:address') || '';
config.version = nconf.get('version');
config.siteTitle = validator.escape(meta.config.title || meta.config.browserTitle || 'NodeBB');
config.browserTitle = validator.escape(meta.config.browserTitle || meta.config.title || 'NodeBB');
config.titleLayout = (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '&#123;').replace(/}/g, '&#125;');
config.showSiteTitle = parseInt(meta.config.showSiteTitle, 10) === 1;
config.postDelay = meta.config.postDelay;
config.minimumTitleLength = meta.config.minimumTitleLength;
config.maximumTitleLength = meta.config.maximumTitleLength;
config.minimumPostLength = meta.config.minimumPostLength;
config.maximumPostLength = meta.config.maximumPostLength;
config.topicStaleDays = parseInt(meta.config.topicStaleDays, 10) || 60;
config.minimumTagsPerTopic = meta.config.minimumTagsPerTopic || 0;
config.maximumTagsPerTopic = meta.config.maximumTagsPerTopic || 5;
config.minimumTagLength = meta.config.minimumTagLength || 3;
config.maximumTagLength = meta.config.maximumTagLength || 15;
config.hasImageUploadPlugin = plugins.hasListeners('filter:uploadImage');
config.maximumProfileImageSize = meta.config.maximumProfileImageSize;
config.minimumUsernameLength = meta.config.minimumUsernameLength;
config.maximumUsernameLength = meta.config.maximumUsernameLength;
config.minimumPasswordLength = meta.config.minimumPasswordLength;
config.maximumSignatureLength = meta.config.maximumSignatureLength;
config.maximumAboutMeLength = meta.config.maximumAboutMeLength || 1000;
config.useOutgoingLinksPage = parseInt(meta.config.useOutgoingLinksPage, 10) === 1;
config.allowGuestSearching = parseInt(meta.config.allowGuestSearching, 10) === 1;
config.allowGuestUserSearching = parseInt(meta.config.allowGuestUserSearching, 10) === 1;
config.allowGuestHandles = parseInt(meta.config.allowGuestHandles, 10) === 1;
config.allowFileUploads = parseInt(meta.config.allowFileUploads, 10) === 1;
config.allowProfileImageUploads = parseInt(meta.config.allowProfileImageUploads) === 1;
config.allowTopicsThumbnail = parseInt(meta.config.allowTopicsThumbnail, 10) === 1;
config.allowAccountDelete = parseInt(meta.config.allowAccountDelete, 10) === 1;
config.allowUserHomePage = parseInt(meta.config.allowUserHomePage, 10) === 1;
config.privateUserInfo = parseInt(meta.config.privateUserInfo, 10) === 1;
config.privateTagListing = parseInt(meta.config.privateTagListing, 10) === 1;
config.usePagination = parseInt(meta.config.usePagination, 10) === 1;
config.disableSocialButtons = parseInt(meta.config.disableSocialButtons, 10) === 1;
config.disableChat = parseInt(meta.config.disableChat, 10) === 1;
config.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
config.socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket'];
config.websocketAddress = nconf.get('socket.io:address') || '';
config.maxReconnectionAttempts = meta.config.maxReconnectionAttempts || 5;
config.reconnectionDelay = meta.config.reconnectionDelay || 1500;
config.minimumTagsPerTopic = meta.config.minimumTagsPerTopic || 0;
config.maximumTagsPerTopic = meta.config.maximumTagsPerTopic || 5;
config.minimumTagLength = meta.config.minimumTagLength || 3;
config.maximumTagLength = meta.config.maximumTagLength || 15;
config.topicsPerPage = meta.config.topicsPerPage || 20;
config.postsPerPage = meta.config.postsPerPage || 20;
config.maximumFileSize = meta.config.maximumFileSize;
@ -77,7 +64,6 @@ apiController.getConfig = function(req, res, next) {
config['theme:src'] = meta.config['theme:src'];
config.defaultLang = meta.config.defaultLang || 'en_GB';
config.userLang = req.query.lang || config.defaultLang;
config.environment = process.env.NODE_ENV;
config.loggedIn = !!req.user;
config['cache-buster'] = meta.config['cache-buster'] || '';
config.requireEmailConfirmation = parseInt(meta.config.requireEmailConfirmation, 10) === 1;

@ -55,11 +55,12 @@ authenticationController.register = function(req, res, next) {
user.isPasswordValid(userData.password, next);
},
function(next) {
res.locals.processLogin = true; // set it to false in plugin if you wish to just register only
plugins.fireHook('filter:register.check', {req: req, res: res, userData: userData}, next);
},
function(data, next) {
if (registrationType === 'normal' || registrationType === 'invite-only') {
registerAndLoginUser(req, userData, next);
registerAndLoginUser(req, res, userData, next);
} else if (registrationType === 'admin-approval') {
addToApprovalQueue(req, userData, next);
}
@ -77,7 +78,7 @@ authenticationController.register = function(req, res, next) {
});
};
function registerAndLoginUser(req, userData, callback) {
function registerAndLoginUser(req, res, userData, callback) {
var uid;
async.waterfall([
function(next) {
@ -85,13 +86,15 @@ function registerAndLoginUser(req, userData, callback) {
},
function(_uid, next) {
uid = _uid;
req.login({uid: uid}, next);
if (res.locals.processLogin === true) {
user.logIP(uid, req.ip);
req.login({uid: uid}, next);
} else {
next();
}
},
function(next) {
user.logIP(uid, req.ip);
user.deleteInvitation(userData.email);
plugins.fireHook('filter:register.complete', {uid: uid, referrer: req.body.referrer || nconf.get('relative_path') + '/'}, next);
}
], callback);

@ -77,6 +77,7 @@ Controllers.reset = function(req, res, next) {
valid: valid,
displayExpiryNotice: req.session.passwordExpired,
code: req.params.code ? req.params.code : null,
minimumPasswordLength: parseInt(meta.config.minimumPasswordLength, 10),
breadcrumbs: helpers.buildBreadcrumbs([{text: '[[reset_password:reset_password]]', url: '/reset'}, {text: '[[reset_password:update_password]]'}]),
title: '[[pages:reset]]'
});
@ -137,9 +138,9 @@ Controllers.register = function(req, res, next) {
data.authentication = loginStrategies;
data.minimumUsernameLength = meta.config.minimumUsernameLength;
data.maximumUsernameLength = meta.config.maximumUsernameLength;
data.minimumPasswordLength = meta.config.minimumPasswordLength;
data.minimumUsernameLength = parseInt(meta.config.minimumUsernameLength, 10);
data.maximumUsernameLength = parseInt(meta.config.maximumUsernameLength, 10);
data.minimumPasswordLength = parseInt(meta.config.minimumPasswordLength, 10);
data.termsOfUse = tos.postData.content;
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[register:register]]'}]);
data.regFormEntry = [];

@ -249,6 +249,7 @@ topicsController.get = function(req, res, callback) {
}
data.privileges = userPrivileges;
data.topicStaleDays = parseInt(meta.config.topicStaleDays, 10) || 60;
data['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;
data['downvote:disabled'] = parseInt(meta.config['downvote:disabled'], 10) === 1;
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;

@ -46,7 +46,7 @@ uploadsController.upload = function(req, res, filesIterator, next) {
uploadsController.uploadPost = function(req, res, next) {
uploadsController.upload(req, res, function(uploadedFile, next) {
if (uploadedFile.type.match(/image./)) {
file.isFileTypeAllowed(uploadedFile.path, function(err) {
file.isFileTypeAllowed(uploadedFile.path, function(err, tempPath) {
if (err) {
return next(err);
}
@ -66,7 +66,7 @@ uploadsController.uploadThumb = function(req, res, next) {
}
uploadsController.upload(req, res, function(uploadedFile, next) {
file.isFileTypeAllowed(uploadedFile.path, function(err) {
file.isFileTypeAllowed(uploadedFile.path, function(err, tempPath) {
if (err) {
return next(err);
}

@ -52,7 +52,7 @@ file.base64ToLocal = function(imageData, uploadPath, callback) {
file.isFileTypeAllowed = function(path, callback) {
// Attempt to read the file, if it passes, file type is allowed
jimp.read(path, function(err) {
callback(err);
callback(err, path);
});
};

@ -9,6 +9,7 @@ var Jimp = require('jimp');
var db = require('../database');
var file = require('../file');
var uploadsController = require('../controllers/uploads');
module.exports = function(Groups) {
@ -38,7 +39,11 @@ module.exports = function(Groups) {
writeImageDataToFile(data.imageData, next);
},
function (_tempPath, next) {
tempPath = _tempPath;
tempPath = _tempPath; // set in local var so it can be deleted if file type invalid
next(null, tempPath);
},
async.apply(file.isFileTypeAllowed),
function (_tempPath, next) {
uploadsController.uploadGroupCover(uid, {
name: 'groupCover',
path: tempPath
@ -65,7 +70,9 @@ module.exports = function(Groups) {
}
], function (err) {
if (err) {
return callback(err);
return fs.unlink(tempPath, function(unlinkErr) {
callback(err); // send back original error
});
}
if (data.position) {

@ -130,6 +130,8 @@ module.exports = function(app, middleware) {
templateValues.customJS = templateValues.useCustomJS ? meta.config.customJS : '';
templateValues.maintenanceHeader = parseInt(meta.config.maintenanceMode, 10) === 1 && !results.isAdmin;
templateValues.defaultLang = meta.config.defaultLang || 'en_GB';
templateValues.privateUserInfo = parseInt(meta.config.privateUserInfo, 10) === 1;
templateValues.privateTagListing = parseInt(meta.config.privateTagListing, 10) === 1;
templateValues.template = {name: res.locals.template};
templateValues.template[res.locals.template] = true;

@ -1,10 +1,11 @@
"use strict";
var navigation = {};
var nconf = require('nconf');
var admin = require('./admin');
var translator = require('../../public/src/modules/translator');
var navigation = {};
navigation.get = function(callback) {
if (admin.cache) {
return callback(null, admin.cache);
@ -18,6 +19,10 @@ navigation.get = function(callback) {
data = data.filter(function(item) {
return item && item.enabled;
}).map(function(item) {
if (!item.route.startsWith('http')) {
item.route = nconf.get('relative_path') + item.route;
}
for (var i in item) {
if (item.hasOwnProperty(i)) {
item[i] = translator.unescape(item[i]);

@ -5,7 +5,8 @@ var meta = require('../meta'),
function sendMinifiedJS(req, res, next) {
res.type('text/javascript').send(meta.js.target['nodebb.min.js'].cache);
var cache = meta.js.target['nodebb.min.js'] ? meta.js.target['nodebb.min.js'].cache : '';
res.type('text/javascript').send(cache);
}
// The portions of code involving the source map are commented out as they're broken in UglifyJS2

@ -94,7 +94,7 @@ module.exports = function(User) {
return;
}
user.username = validator.escape(user.username);
user.username = validator.escape(user.username || '');
if (user.password) {
user.password = undefined;

@ -38,7 +38,7 @@ module.exports = function(User) {
function(next) {
file.isFileTypeAllowed(picture.path, next);
},
function(next) {
function(path, next) {
image.resizeImage({
path: picture.path,
extension: extension,
@ -168,6 +168,9 @@ module.exports = function(User) {
}, next);
},
function(next) {
file.isFileTypeAllowed(tempPath, next);
},
function(tempPath, next) {
var image = {
name: 'profileCover',
path: data.file ? data.file.path : tempPath,
@ -204,7 +207,9 @@ module.exports = function(User) {
}
], function(err) {
if (err) {
return callback(err);
return fs.unlink(tempPath, function(unlinkErr) {
callback(err); // send back the original error
});
}
if (data.position) {

@ -7,7 +7,7 @@
<div class="form-group">
<div class="checkbox">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input type="checkbox" class="mdl-switch__input" id="showSiteTitle" data-field="disableChat">
<input type="checkbox" class="mdl-switch__input" id="disableChat" data-field="disableChat">
<span class="mdl-switch__label"><strong>Disable chat</strong></span>
</label>
</div>

@ -1,9 +1,8 @@
'use strict';
/*global require*/
var assert = require('assert'),
db = require('./mocks/databasemock'),
translator = require('../public/src/modules/translator.js');
var assert = require('assert');
var translator = require('../public/src/modules/translator.js');
describe('Translator', function(){
@ -84,6 +83,7 @@ describe('Translator', function(){
assert.strictEqual(translated, 'Perhaps you should <a href=\'&lt;strong&gt;test&lt;/strong&gt;/login\'>try logging in</a>?');
done();
});
})
});
});
});

Loading…
Cancel
Save