Compare commits

...

15 Commits

Author SHA1 Message Date
Barış Soner Uşaklı
e8ca993aac feat: add new client side hooks 2020-12-16 11:16:00 -05:00
Barış Soner Uşaklı
2b29dfe8e7 fix: #9117, lower query before search 2020-12-16 11:15:49 -05:00
Barış Soner Uşaklı
2b586764e2 fix: #9081, load raw settings before merging 2020-12-07 12:20:39 -05:00
Julian Lam
07f8ab4e70 fix: #9063, missing handler for passwordless accounts in admin.checkPrivileges middleware 2020-12-05 10:03:40 -05:00
Barış Soner Uşaklı
c4e3d84b38 fix: redirect external with absolute urls 2020-12-03 17:20:54 -05:00
Barış Soner Uşaklı
a815cfdfed fix: external path for subfolder installs 2020-12-03 15:01:13 -05:00
Misty (Bot)
8245015cee chore: incrementing version number - v1.15.5 2020-12-03 19:27:45 +00:00
Misty (Bot)
2d39868dc3 Merge commit '64ac483dddb65ad6cba06a2e2a43a07a361546f1' into v1.15.x 2020-12-03 19:27:45 +00:00
Misty (Bot)
e0f77d1791 chore: incrementing version number - v1.15.4 2020-12-02 22:15:27 +00:00
Misty (Bot)
a2cb768ac0 Merge commit '73746bb4897425f6271070650b8ad4d247d0a262' into v1.15.x 2020-12-02 22:15:26 +00:00
Misty (Bot)
c0d406ae68 chore: incrementing version number - v1.15.3 2020-11-26 01:11:08 +00:00
Misty (Bot)
7c73ec75c6 Merge commit '7de8b732c040228838ae2f999f823849f2386ad0' into v1.15.x 2020-11-26 01:11:07 +00:00
Misty (Bot)
ce5c0ee6e7 chore: incrementing version number - v1.15.2 2020-11-18 19:42:37 +00:00
Misty (Bot)
6528e9e402 Merge commit 'fa4177c3bc0b0a4b4c81632d406b653963922cd7' into v1.15.x 2020-11-18 19:42:37 +00:00
Misty (Bot)
2790a3a3fe chore: incrementing version number - v1.15.1 2020-11-11 22:51:05 +00:00
8 changed files with 54 additions and 21 deletions

View File

@@ -2,7 +2,7 @@
"name": "nodebb", "name": "nodebb",
"license": "GPL-3.0", "license": "GPL-3.0",
"description": "NodeBB Forum", "description": "NodeBB Forum",
"version": "1.15.4", "version": "1.15.5",
"homepage": "http://www.nodebb.org", "homepage": "http://www.nodebb.org",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -338,7 +338,13 @@ define('forum/topic/postTools', [
function bookmarkPost(button, pid) { function bookmarkPost(button, pid) {
var method = button.attr('data-bookmarked') === 'false' ? 'put' : 'del'; var method = button.attr('data-bookmarked') === 'false' ? 'put' : 'del';
api[method](`/posts/${pid}/bookmark`, undefined, undefined, 'default'); api[method](`/posts/${pid}/bookmark`, undefined, function (err) {
if (err) {
return app.alertError(err);
}
var type = method === 'put' ? 'bookmark' : 'unbookmark';
$(window).trigger('action:post.' + type, { pid: pid });
});
return false; return false;
} }
@@ -429,6 +435,7 @@ define('forum/topic/postTools', [
$(window).trigger('action:composer.topic.new', { $(window).trigger('action:composer.topic.new', {
cid: ajaxify.data.cid, cid: ajaxify.data.cid,
body: body, body: body,
fromStaleTopic: true,
}); });
}); });
}, },

View File

@@ -58,14 +58,22 @@ define('forum/topic/votes', [
var currentState = post.find(className).length; var currentState = post.find(className).length;
const method = currentState ? 'del' : 'put'; const method = currentState ? 'del' : 'put';
api[method](`/posts/${post.attr('data-pid')}/vote`, { var pid = post.attr('data-pid');
api[method](`/posts/${pid}/vote`, {
delta: delta, delta: delta,
}).catch((err) => { }, function (err) {
app.alertError(err.message); if (err) {
if (err.message === '[[error:not-logged-in]]') {
if (err.message === '[[error:not-logged-in]]') { ajaxify.go('login');
ajaxify.go('login'); return;
}
return app.alertError(err.message);
} }
$(window).trigger('action:post.toggleVote', {
pid: pid,
delta: delta,
unvote: method === 'del',
});
}); });
return false; return false;

View File

@@ -9,6 +9,10 @@ define('share', function () {
function openShare(url, urlToPost, width, height) { function openShare(url, urlToPost, width, height) {
window.open(url + encodeURIComponent(baseUrl + config.relative_path + urlToPost), '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no'); window.open(url + encodeURIComponent(baseUrl + config.relative_path + urlToPost), '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no');
$(window).trigger('action:share.open', {
url: url,
urlToPost: urlToPost,
});
return false; return false;
} }

View File

@@ -109,7 +109,8 @@ usersAPI.updateSettings = async function (caller, data) {
throw new Error('[[error:no-privileges]]'); throw new Error('[[error:no-privileges]]');
} }
const current = await user.getSettings(data.uid); // load raw settings without parsing values to booleans
const current = await db.getObject('user:' + data.uid + ':settings');
const payload = { ...current, ...data.settings }; const payload = { ...current, ...data.settings };
delete payload.uid; delete payload.uid;

View File

@@ -147,7 +147,7 @@ usersController.search = async function (req, res) {
if (!query || query.length < 2) { if (!query || query.length < 2) {
return []; return [];
} }
hardCap = hardCap || resultsPerPage * 10; query = String(query).toLowerCase();
if (!query.endsWith('*')) { if (!query.endsWith('*')) {
query += '*'; query += '*';
} }
@@ -155,7 +155,7 @@ usersController.search = async function (req, res) {
const data = await db.getSortedSetScan({ const data = await db.getSortedSetScan({
key: searchBy + ':sorted', key: searchBy + ':sorted',
match: query, match: query,
limit: hardCap, limit: hardCap || (resultsPerPage * 10),
}); });
return data.map(data => data.split(':').pop()); return data.map(data => data.split(':').pop());
}, },

View File

@@ -145,24 +145,31 @@ helpers.notAllowed = async function (req, res, error) {
}; };
helpers.redirect = function (res, url, permanent) { helpers.redirect = function (res, url, permanent) {
let redirectUrl;
// this is used by sso plugins to redirect to the auth route // this is used by sso plugins to redirect to the auth route
// { external: '/auth/sso' } or { external: 'https://domain/auth/sso' }
if (url.hasOwnProperty('external')) { if (url.hasOwnProperty('external')) {
redirectUrl = url.external; const redirectUrl = encodeURI(prependRelativePath(url.external));
url.external = encodeURI(url.external); if (res.locals.isAPI) {
} else { res.set('X-Redirect', redirectUrl).status(200).json({ external: redirectUrl });
redirectUrl = url; } else {
url = encodeURI(url); res.redirect(permanent ? 308 : 307, redirectUrl);
}
return;
} }
if (res.locals.isAPI) { if (res.locals.isAPI) {
res.set('X-Redirect', encodeURI(redirectUrl)).status(200).json(url); url = encodeURI(url);
res.set('X-Redirect', url).status(200).json(url);
} else { } else {
redirectUrl = redirectUrl.startsWith('http://') || redirectUrl.startsWith('https://') ? res.redirect(permanent ? 308 : 307, encodeURI(prependRelativePath(url)));
redirectUrl : relative_path + redirectUrl;
res.redirect(permanent ? 308 : 307, encodeURI(redirectUrl));
} }
}; };
function prependRelativePath(url) {
return url.startsWith('http://') || url.startsWith('https://') ?
url : relative_path + url;
}
helpers.buildCategoryBreadcrumbs = async function (cid) { helpers.buildCategoryBreadcrumbs = async function (cid) {
const breadcrumbs = []; const breadcrumbs = [];

View File

@@ -124,6 +124,12 @@ middleware.checkPrivileges = helpers.try(async (req, res, next) => {
} }
} }
// If user does not have password
const hasPassword = await user.hasPassword(req.uid);
if (!hasPassword) {
return next();
}
// Reject if they need to re-login (due to ACP timeout), otherwise extend logout timer // Reject if they need to re-login (due to ACP timeout), otherwise extend logout timer
const loginTime = req.session.meta ? req.session.meta.datetime : 0; const loginTime = req.session.meta ? req.session.meta.datetime : 0;
const adminReloginDuration = meta.config.adminReloginDuration * 60000; const adminReloginDuration = meta.config.adminReloginDuration * 60000;