mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 15:48:43 +02:00
Merge remote-tracking branch 'origin/master' into web-install
This commit is contained in:
@@ -10,7 +10,9 @@ define('forum/account/favourites', ['forum/account/header', 'forum/infinitescrol
|
||||
|
||||
$('.user-favourite-posts img').addClass('img-responsive');
|
||||
|
||||
infinitescroll.init(loadMore);
|
||||
if (!config.usePagination) {
|
||||
infinitescroll.init(loadMore);
|
||||
}
|
||||
};
|
||||
|
||||
function loadMore(direction) {
|
||||
@@ -24,10 +26,10 @@ define('forum/account/favourites', ['forum/account/header', 'forum/infinitescrol
|
||||
}, function(data, done) {
|
||||
if (data.posts && data.posts.length) {
|
||||
onPostsLoaded(data.posts, done);
|
||||
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
||||
|
||||
$('.user-favourite-posts img').addClass('img-responsive');
|
||||
|
||||
infinitescroll.init(loadMore);
|
||||
if (!config.usePagination) {
|
||||
infinitescroll.init(loadMore);
|
||||
}
|
||||
};
|
||||
|
||||
function loadMore(direction) {
|
||||
@@ -24,10 +26,10 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
||||
}, function(data, done) {
|
||||
if (data.posts && data.posts.length) {
|
||||
onPostsLoaded(data.posts, done);
|
||||
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
|
||||
AccountTopics.init = function() {
|
||||
header.init();
|
||||
|
||||
infinitescroll.init(loadMore);
|
||||
if (!config.usePagination) {
|
||||
infinitescroll.init(loadMore);
|
||||
}
|
||||
};
|
||||
|
||||
function loadMore(direction) {
|
||||
@@ -23,10 +25,10 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
|
||||
|
||||
if (data.topics && data.topics.length) {
|
||||
onTopicsLoaded(data.topics, done);
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ define('forum/account/watched', ['forum/account/header', 'forum/infinitescroll']
|
||||
AccountWatched.init = function() {
|
||||
header.init();
|
||||
|
||||
infinitescroll.init(loadMore);
|
||||
if (!config.usePagination) {
|
||||
infinitescroll.init(loadMore);
|
||||
}
|
||||
};
|
||||
|
||||
function loadMore(direction) {
|
||||
@@ -21,10 +23,10 @@ define('forum/account/watched', ['forum/account/header', 'forum/infinitescroll']
|
||||
}, function(data, done) {
|
||||
if (data.topics && data.topics.length) {
|
||||
onTopicsLoaded(data.topics, done);
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -342,17 +342,16 @@ define('forum/category', [
|
||||
after: after,
|
||||
author: utils.params().author
|
||||
}, function (data, done) {
|
||||
|
||||
if (data.topics && data.topics.length) {
|
||||
Category.onTopicsLoaded(data, function() {
|
||||
done();
|
||||
callback();
|
||||
});
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
$(window).trigger('action:categories.loaded');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,10 +93,10 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
}, function(data, done) {
|
||||
if (data.topics && data.topics.length) {
|
||||
Recent.onTopicsLoaded('recent', data.topics, false, done);
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ define('forum/tag', ['forum/recent', 'forum/infinitescroll'], function(recent, i
|
||||
}, function(data, done) {
|
||||
if (data.topics && data.topics.length) {
|
||||
recent.onTopicsLoaded('tag', data.topics, false, done);
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
} else {
|
||||
done();
|
||||
$('#load-more-btn').hide();
|
||||
}
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -255,22 +255,51 @@ accountsController.getGroups = function(req, res, next) {
|
||||
};
|
||||
|
||||
function getFromUserSet(tpl, set, method, type, req, res, next) {
|
||||
accountsController.getBaseUser(req.params.userslug, req.uid, function(err, userData) {
|
||||
async.parallel({
|
||||
settings: function(next) {
|
||||
user.getSettings(req.uid, next);
|
||||
},
|
||||
userData: function(next) {
|
||||
accountsController.getBaseUser(req.params.userslug, req.uid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
var userData = results.userData;
|
||||
if (!userData) {
|
||||
return helpers.notFound(req, res);
|
||||
}
|
||||
|
||||
method('uid:' + userData.uid + ':' + set, req.uid, 0, 19, function(err, data) {
|
||||
var setName = 'uid:' + userData.uid + ':' + set;
|
||||
|
||||
var page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
||||
var itemsPerPage = (tpl === 'account/topics' || tpl === 'account/watched') ? results.settings.topicsPerPage : results.settings.postsPerPage;
|
||||
|
||||
async.parallel({
|
||||
itemCount: function(next) {
|
||||
if (results.settings.usePagination) {
|
||||
db.sortedSetCard(setName, next);
|
||||
} else {
|
||||
next(null, 0);
|
||||
}
|
||||
},
|
||||
data: function(next) {
|
||||
var start = (page - 1) * itemsPerPage;
|
||||
var stop = start + itemsPerPage;
|
||||
method(setName, req.uid, start, stop, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
userData[type] = data[type];
|
||||
userData.nextStart = data.nextStart;
|
||||
userData[type] = results.data[type];
|
||||
userData.nextStart = results.data.nextStart;
|
||||
var pageCount = Math.ceil(results.itemCount / itemsPerPage);
|
||||
|
||||
var pagination = require('../pagination');
|
||||
userData.pagination = pagination.create(page, pageCount);
|
||||
|
||||
res.render(tpl, userData);
|
||||
});
|
||||
|
||||
@@ -81,7 +81,7 @@ Controllers.login = function(req, res, next) {
|
||||
data.alternate_logins = loginStrategies.length > 0;
|
||||
data.authentication = loginStrategies;
|
||||
data.showResetLink = emailersPresent;
|
||||
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1;
|
||||
data.allowLocalLogin = parseInt(meta.config.allowLocalLogin, 10) === 1 || parseInt(req.query.local, 10) === 1;
|
||||
data.allowRegistration = parseInt(meta.config.allowRegistration, 10) === 1;
|
||||
data.allowLoginWith = '[[login:' + (meta.config.allowLoginWith || 'username-email') + ']]';
|
||||
data.breadcrumbs = helpers.buildBreadcrumbs([{text: '[[global:login]]'}]);
|
||||
|
||||
@@ -10,18 +10,19 @@ var app,
|
||||
winston = require('winston'),
|
||||
validator = require('validator'),
|
||||
nconf = require('nconf'),
|
||||
|
||||
plugins = require('./../plugins'),
|
||||
navigation = require('./../navigation'),
|
||||
meta = require('./../meta'),
|
||||
translator = require('./../../public/src/modules/translator'),
|
||||
user = require('./../user'),
|
||||
groups = require('./../groups'),
|
||||
db = require('./../database'),
|
||||
categories = require('./../categories'),
|
||||
topics = require('./../topics'),
|
||||
messaging = require('../messaging'),
|
||||
ensureLoggedIn = require('connect-ensure-login'),
|
||||
|
||||
plugins = require('../plugins'),
|
||||
navigation = require('../navigation'),
|
||||
meta = require('../meta'),
|
||||
translator = require('../../public/src/modules/translator'),
|
||||
user = require('../user'),
|
||||
groups = require('../groups'),
|
||||
db = require('../database'),
|
||||
categories = require('../categories'),
|
||||
topics = require('../topics'),
|
||||
messaging = require('../messaging'),
|
||||
|
||||
analytics = require('../analytics'),
|
||||
|
||||
controllers = {
|
||||
|
||||
@@ -13,7 +13,7 @@ pagination.create = function(currentPage, pageCount, queryObj) {
|
||||
pages: []
|
||||
};
|
||||
}
|
||||
|
||||
pageCount = parseInt(pageCount, 10);
|
||||
var pagesToShow = [1, 2, pageCount - 1, pageCount];
|
||||
|
||||
currentPage = parseInt(currentPage, 10) || 1;
|
||||
|
||||
@@ -101,11 +101,23 @@
|
||||
user.auth.logAttempt(uid, req.ip, next);
|
||||
},
|
||||
function(next) {
|
||||
db.getObjectFields('user:' + uid, ['password', 'banned', 'passwordExpiry'], next);
|
||||
async.parallel({
|
||||
userData: function(next) {
|
||||
db.getObjectFields('user:' + uid, ['password', 'banned', 'passwordExpiry'], next);
|
||||
},
|
||||
isAdmin: function(next) {
|
||||
user.isAdministrator(uid, next);
|
||||
}
|
||||
}, next);
|
||||
},
|
||||
function(_userData, next) {
|
||||
userData = _userData;
|
||||
function(result, next) {
|
||||
userData = result.userData;
|
||||
userData.uid = uid;
|
||||
userData.isAdmin = result.isAdmin;
|
||||
|
||||
if (!result.isAdmin && parseInt(meta.config.allowLocalLogin, 10) === 0) {
|
||||
return next(new Error('[[error:local-login-disabled]]'));
|
||||
}
|
||||
|
||||
if (!userData || !userData.password) {
|
||||
return next(new Error('[[error:invalid-user-data]]'));
|
||||
@@ -136,10 +148,6 @@
|
||||
});
|
||||
|
||||
function login(req, res, next) {
|
||||
if (parseInt(meta.config.allowLocalLogin, 10) === 0) {
|
||||
return res.status(404).send('');
|
||||
}
|
||||
|
||||
// Handle returnTo data
|
||||
if (req.body.hasOwnProperty('returnTo') && !req.session.returnTo) {
|
||||
req.session.returnTo = req.body.returnTo;
|
||||
@@ -147,7 +155,7 @@
|
||||
|
||||
if (plugins.hasListeners('action:auth.overrideLogin')) {
|
||||
return Auth.continueLogin(req, res, next);
|
||||
};
|
||||
}
|
||||
|
||||
var loginWith = meta.config.allowLoginWith || 'username-email';
|
||||
|
||||
|
||||
@@ -118,7 +118,9 @@ module.exports = function(app, middleware) {
|
||||
|
||||
app.all(relativePath + '/api/?*', middleware.prepareAPI);
|
||||
app.all(relativePath + '/api/admin/?*', middleware.isAdmin);
|
||||
app.all(relativePath + '/admin/?*', middleware.ensureLoggedIn, middleware.applyCSRF, middleware.isAdmin);
|
||||
|
||||
var ensureLoggedIn = require('connect-ensure-login');
|
||||
app.all(relativePath + '/admin/?*', ensureLoggedIn.ensureLoggedIn(nconf.get('relative_path') + '/login?local=1'), middleware.applyCSRF, middleware.isAdmin);
|
||||
|
||||
adminRoutes(router, middleware, controllers);
|
||||
metaRoutes(router, middleware, controllers);
|
||||
|
||||
Reference in New Issue
Block a user