mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-16 21:40:23 +01:00
Compare commits
15 Commits
custom-use
...
v1.15.x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8ca993aac | ||
|
|
2b29dfe8e7 | ||
|
|
2b586764e2 | ||
|
|
07f8ab4e70 | ||
|
|
c4e3d84b38 | ||
|
|
a815cfdfed | ||
|
|
8245015cee | ||
|
|
2d39868dc3 | ||
|
|
e0f77d1791 | ||
|
|
a2cb768ac0 | ||
|
|
c0d406ae68 | ||
|
|
7c73ec75c6 | ||
|
|
ce5c0ee6e7 | ||
|
|
6528e9e402 | ||
|
|
2790a3a3fe |
@@ -2,7 +2,7 @@
|
||||
"name": "nodebb",
|
||||
"license": "GPL-3.0",
|
||||
"description": "NodeBB Forum",
|
||||
"version": "1.15.4",
|
||||
"version": "1.15.5",
|
||||
"homepage": "http://www.nodebb.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -338,7 +338,13 @@ define('forum/topic/postTools', [
|
||||
function bookmarkPost(button, pid) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -429,6 +435,7 @@ define('forum/topic/postTools', [
|
||||
$(window).trigger('action:composer.topic.new', {
|
||||
cid: ajaxify.data.cid,
|
||||
body: body,
|
||||
fromStaleTopic: true,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -58,14 +58,22 @@ define('forum/topic/votes', [
|
||||
var currentState = post.find(className).length;
|
||||
|
||||
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,
|
||||
}).catch((err) => {
|
||||
app.alertError(err.message);
|
||||
|
||||
if (err.message === '[[error:not-logged-in]]') {
|
||||
ajaxify.go('login');
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
if (err.message === '[[error:not-logged-in]]') {
|
||||
ajaxify.go('login');
|
||||
return;
|
||||
}
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
$(window).trigger('action:post.toggleVote', {
|
||||
pid: pid,
|
||||
delta: delta,
|
||||
unvote: method === 'del',
|
||||
});
|
||||
});
|
||||
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,10 @@ define('share', function () {
|
||||
|
||||
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).trigger('action:share.open', {
|
||||
url: url,
|
||||
urlToPost: urlToPost,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,8 @@ usersAPI.updateSettings = async function (caller, data) {
|
||||
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 };
|
||||
delete payload.uid;
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ usersController.search = async function (req, res) {
|
||||
if (!query || query.length < 2) {
|
||||
return [];
|
||||
}
|
||||
hardCap = hardCap || resultsPerPage * 10;
|
||||
query = String(query).toLowerCase();
|
||||
if (!query.endsWith('*')) {
|
||||
query += '*';
|
||||
}
|
||||
@@ -155,7 +155,7 @@ usersController.search = async function (req, res) {
|
||||
const data = await db.getSortedSetScan({
|
||||
key: searchBy + ':sorted',
|
||||
match: query,
|
||||
limit: hardCap,
|
||||
limit: hardCap || (resultsPerPage * 10),
|
||||
});
|
||||
return data.map(data => data.split(':').pop());
|
||||
},
|
||||
|
||||
@@ -145,24 +145,31 @@ helpers.notAllowed = async function (req, res, error) {
|
||||
};
|
||||
|
||||
helpers.redirect = function (res, url, permanent) {
|
||||
let redirectUrl;
|
||||
// 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')) {
|
||||
redirectUrl = url.external;
|
||||
url.external = encodeURI(url.external);
|
||||
} else {
|
||||
redirectUrl = url;
|
||||
url = encodeURI(url);
|
||||
const redirectUrl = encodeURI(prependRelativePath(url.external));
|
||||
if (res.locals.isAPI) {
|
||||
res.set('X-Redirect', redirectUrl).status(200).json({ external: redirectUrl });
|
||||
} else {
|
||||
res.redirect(permanent ? 308 : 307, redirectUrl);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
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 {
|
||||
redirectUrl = redirectUrl.startsWith('http://') || redirectUrl.startsWith('https://') ?
|
||||
redirectUrl : relative_path + redirectUrl;
|
||||
res.redirect(permanent ? 308 : 307, encodeURI(redirectUrl));
|
||||
res.redirect(permanent ? 308 : 307, encodeURI(prependRelativePath(url)));
|
||||
}
|
||||
};
|
||||
|
||||
function prependRelativePath(url) {
|
||||
return url.startsWith('http://') || url.startsWith('https://') ?
|
||||
url : relative_path + url;
|
||||
}
|
||||
|
||||
helpers.buildCategoryBreadcrumbs = async function (cid) {
|
||||
const breadcrumbs = [];
|
||||
|
||||
|
||||
@@ -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
|
||||
const loginTime = req.session.meta ? req.session.meta.datetime : 0;
|
||||
const adminReloginDuration = meta.config.adminReloginDuration * 60000;
|
||||
|
||||
Reference in New Issue
Block a user