mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 04:37:51 +02:00
closes #2304
This commit is contained in:
@@ -97,7 +97,7 @@ chatsController.get = function (req, res, callback) {
|
||||
|
||||
chatsController.redirectToChat = function (req, res, next) {
|
||||
var roomid = parseInt(req.params.roomid, 10);
|
||||
if (!req.uid) {
|
||||
if (!req.loggedIn) {
|
||||
return next();
|
||||
}
|
||||
async.waterfall([
|
||||
|
||||
@@ -13,7 +13,7 @@ categoriesController.get = function (req, res, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
category: async.apply(categories.getCategories, [req.params.category_id], req.user.uid),
|
||||
category: async.apply(categories.getCategories, [req.params.category_id], req.uid),
|
||||
allCategories: async.apply(categories.buildForSelect, req.uid, 'read'),
|
||||
}, next);
|
||||
},
|
||||
|
||||
@@ -253,7 +253,7 @@ function uploadImage(filename, folder, uploadedFile, req, res, next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (plugins.hasListeners('filter:uploadImage')) {
|
||||
plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.user.uid }, next);
|
||||
plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.uid }, next);
|
||||
} else {
|
||||
file.saveFileToLocal(filename, folder, uploadedFile.path, next);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ usersController.getCSV = function (req, res, next) {
|
||||
}
|
||||
events.log({
|
||||
type: 'getUsersCSV',
|
||||
uid: req.user.uid,
|
||||
uid: req.uid,
|
||||
ip: req.ip,
|
||||
});
|
||||
async.waterfall([
|
||||
|
||||
@@ -78,7 +78,7 @@ apiController.loadConfig = function (req, callback) {
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (!req.uid) {
|
||||
if (!req.loggedIn) {
|
||||
return next(null, config);
|
||||
}
|
||||
user.getSettings(req.uid, next);
|
||||
|
||||
@@ -417,7 +417,7 @@ authenticationController.localLogin = function (req, username, password, next) {
|
||||
};
|
||||
|
||||
authenticationController.logout = function (req, res, next) {
|
||||
if (!req.uid || !req.sessionID) {
|
||||
if (!req.loggedIn || !req.sessionID) {
|
||||
return res.status(200).send('not-logged-in');
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ helpers.noScriptErrors = function (req, res, error, httpStatus) {
|
||||
middleware.buildHeader(req, res, function () {
|
||||
res.status(httpStatus).render(httpStatusString, {
|
||||
path: req.path,
|
||||
loggedIn: true,
|
||||
loggedIn: req.loggedIn,
|
||||
error: error,
|
||||
returnLink: true,
|
||||
title: '[[global:' + httpStatusString + '.title]]',
|
||||
@@ -67,11 +67,11 @@ helpers.notAllowed = function (req, res, error) {
|
||||
if (err) {
|
||||
return winston.error(err);
|
||||
}
|
||||
if (req.uid) {
|
||||
if (req.loggedIn) {
|
||||
if (res.locals.isAPI) {
|
||||
res.status(403).json({
|
||||
path: req.path.replace(/^\/api/, ''),
|
||||
loggedIn: !!req.uid,
|
||||
loggedIn: req.loggedIn,
|
||||
error: error,
|
||||
title: '[[global:403.title]]',
|
||||
});
|
||||
@@ -79,7 +79,7 @@ helpers.notAllowed = function (req, res, error) {
|
||||
middleware.buildHeader(req, res, function () {
|
||||
res.status(403).render('403', {
|
||||
path: req.path,
|
||||
loggedIn: !!req.uid,
|
||||
loggedIn: req.loggedIn,
|
||||
error: error,
|
||||
title: '[[global:403.title]]',
|
||||
});
|
||||
|
||||
@@ -113,7 +113,7 @@ Controllers.login = function (req, res, next) {
|
||||
}
|
||||
return res.redirect(nconf.get('relative_path') + data.authentication[0].url);
|
||||
}
|
||||
if (req.uid) {
|
||||
if (req.loggedIn) {
|
||||
user.getUserFields(req.uid, ['username', 'email'], function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
|
||||
@@ -37,7 +37,7 @@ popularController.get = function (req, res, next) {
|
||||
alltime: '[[global:header.popular]]',
|
||||
};
|
||||
|
||||
if (!req.uid) {
|
||||
if (!req.loggedIn) {
|
||||
if (anonCache[term] && (Date.now() - lastUpdateTime) < 60 * 60 * 1000) {
|
||||
return res.render('popular', anonCache[term]);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ popularController.get = function (req, res, next) {
|
||||
data.breadcrumbs = helpers.buildBreadcrumbs(breadcrumbs);
|
||||
}
|
||||
|
||||
if (!req.uid) {
|
||||
if (!req.loggedIn) {
|
||||
anonCache[term] = data;
|
||||
lastUpdateTime = Date.now();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ recentController.get = function (req, res, next) {
|
||||
data.set = 'topics:recent';
|
||||
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
||||
data.rssFeedUrl = nconf.get('relative_path') + '/recent.rss';
|
||||
if (req.uid) {
|
||||
if (req.loggedIn) {
|
||||
data.rssFeedUrl += '?uid=' + req.uid + '&token=' + rssToken;
|
||||
}
|
||||
data.title = meta.config.homePageTitle || '[[pages:home]]';
|
||||
|
||||
@@ -11,15 +11,14 @@ var categories = require('../categories');
|
||||
var pagination = require('../pagination');
|
||||
var helpers = require('./helpers');
|
||||
|
||||
|
||||
var searchController = {};
|
||||
var searchController = module.exports;
|
||||
|
||||
searchController.search = function (req, res, next) {
|
||||
if (!plugins.hasListeners('filter:search.query')) {
|
||||
return next();
|
||||
}
|
||||
|
||||
if (!req.user && parseInt(meta.config.allowGuestSearching, 10) !== 1) {
|
||||
if (!req.loggedIn && parseInt(meta.config.allowGuestSearching, 10) !== 1) {
|
||||
return helpers.notAllowed(req, res);
|
||||
}
|
||||
|
||||
@@ -78,5 +77,3 @@ searchController.search = function (req, res, next) {
|
||||
res.render('search', searchData);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = searchController;
|
||||
|
||||
@@ -58,7 +58,7 @@ topController.get = function (req, res, next) {
|
||||
data.set = 'topics:votes';
|
||||
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
||||
data.rssFeedUrl = nconf.get('relative_path') + '/top.rss';
|
||||
if (req.uid) {
|
||||
if (req.loggedIn) {
|
||||
data.rssFeedUrl += '?uid=' + req.uid + '&token=' + rssToken;
|
||||
}
|
||||
data.title = meta.config.homePageTitle || '[[pages:home]]';
|
||||
|
||||
@@ -146,7 +146,7 @@ topicsController.get = function (req, res, callback) {
|
||||
topicData.postDeleteDuration = parseInt(meta.config.postDeleteDuration, 10) || 0;
|
||||
topicData.scrollToMyPost = settings.scrollToMyPost;
|
||||
topicData.rssFeedUrl = nconf.get('relative_path') + '/topic/' + topicData.tid + '.rss';
|
||||
if (req.uid) {
|
||||
if (req.loggedIn) {
|
||||
topicData.rssFeedUrl += '?uid=' + req.uid + '&token=' + rssToken;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ topicsController.get = function (req, res, callback) {
|
||||
req.session.tids_viewed[tid] = Date.now();
|
||||
}
|
||||
|
||||
if (req.uid) {
|
||||
if (req.loggedIn) {
|
||||
topics.markAsRead([tid], req.uid, function (err, markedRead) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
||||
@@ -9,7 +9,7 @@ var accountHelpers = require('./accounts/helpers');
|
||||
var userController = module.exports;
|
||||
|
||||
userController.getCurrentUser = function (req, res, next) {
|
||||
if (!req.uid) {
|
||||
if (!req.loggedIn) {
|
||||
return res.status(401).json('not-authorized');
|
||||
}
|
||||
async.waterfall([
|
||||
|
||||
Reference in New Issue
Block a user