mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-16 21:40:23 +01:00
Compare commits
37 Commits
custom-use
...
v1.14.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
668ad8abf7 | ||
|
|
f5ba852e78 | ||
|
|
8479809a73 | ||
|
|
311675916a | ||
|
|
c98f55b454 | ||
|
|
c2477d9d5f | ||
|
|
28970b030d | ||
|
|
b54c54f62b | ||
|
|
ddf5c3bf7f | ||
|
|
afe1073e03 | ||
|
|
1c0eb70046 | ||
|
|
28302c55dc | ||
|
|
e0d285032d | ||
|
|
6bb0241daf | ||
|
|
a2c62f2e11 | ||
|
|
f01ac65c5a | ||
|
|
c07cca574f | ||
|
|
226620140c | ||
|
|
2ee196b4da | ||
|
|
b3c4db621a | ||
|
|
592b880b1c | ||
|
|
553dbd73ba | ||
|
|
6721d4151e | ||
|
|
64c0e1433b | ||
|
|
d142e7c86a | ||
|
|
5acf5acb3a | ||
|
|
830c59eb4f | ||
|
|
60ba66c0a3 | ||
|
|
470835e6f7 | ||
|
|
7b4d726c5d | ||
|
|
a49b774800 | ||
|
|
0569c27c88 | ||
|
|
4e1c26becb | ||
|
|
5aea87ade2 | ||
|
|
d93eba9f3b | ||
|
|
626def8b31 | ||
|
|
a10b5eade8 |
@@ -2,7 +2,7 @@
|
||||
"name": "nodebb",
|
||||
"license": "GPL-3.0",
|
||||
"description": "NodeBB Forum",
|
||||
"version": "1.14.2-beta.1",
|
||||
"version": "1.14.3",
|
||||
"homepage": "http://www.nodebb.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -89,7 +89,7 @@
|
||||
"nodebb-plugin-soundpack-default": "1.0.0",
|
||||
"nodebb-plugin-spam-be-gone": "0.7.2",
|
||||
"nodebb-rewards-essentials": "0.1.3",
|
||||
"nodebb-theme-lavender": "5.0.11",
|
||||
"nodebb-theme-lavender": "5.1.0",
|
||||
"nodebb-theme-persona": "10.1.65",
|
||||
"nodebb-theme-slick": "1.2.29",
|
||||
"nodebb-theme-vanilla": "11.1.33",
|
||||
|
||||
@@ -264,7 +264,9 @@ function continueLogin(req, res, next) {
|
||||
await authenticationController.doLogin(req, userData.uid);
|
||||
var destination;
|
||||
if (req.session.returnTo) {
|
||||
destination = req.session.returnTo;
|
||||
destination = req.session.returnTo.startsWith('http') ?
|
||||
req.session.returnTo :
|
||||
nconf.get('relative_path') + req.session.returnTo;
|
||||
delete req.session.returnTo;
|
||||
} else {
|
||||
destination = nconf.get('relative_path') + '/';
|
||||
|
||||
@@ -280,13 +280,18 @@ module.exports = function (User) {
|
||||
}
|
||||
let isAdminOrPasswordMatch = false;
|
||||
const isSelf = parseInt(uid, 10) === parseInt(data.uid, 10);
|
||||
|
||||
if (!isAdmin && !isSelf) {
|
||||
throw new Error('[[user:change_password_error_privileges]]');
|
||||
}
|
||||
|
||||
if (
|
||||
(isAdmin && !isSelf) || // Admins ok
|
||||
(!hasPassword && isSelf) // Initial password set ok
|
||||
) {
|
||||
isAdminOrPasswordMatch = true;
|
||||
} else {
|
||||
isAdminOrPasswordMatch = await User.isPasswordCorrect(uid, data.currentPassword, data.ip);
|
||||
isAdminOrPasswordMatch = await User.isPasswordCorrect(data.uid, data.currentPassword, data.ip);
|
||||
}
|
||||
|
||||
if (!isAdminOrPasswordMatch) {
|
||||
|
||||
36
test/user.js
36
test/user.js
@@ -816,6 +816,42 @@ describe('User', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not let user change another user\'s password', async function () {
|
||||
const regularUserUid = await User.create({ username: 'regularuserpwdchange', password: 'regularuser1234' });
|
||||
const uid = await User.create({ username: 'changeadminpwd1', password: '123456' });
|
||||
let err;
|
||||
try {
|
||||
await socketUser.changePassword({ uid: uid }, { uid: regularUserUid, newPassword: '654321', currentPassword: '123456' });
|
||||
} catch (_err) {
|
||||
err = _err;
|
||||
}
|
||||
assert.equal(err.message, '[[user:change_password_error_privileges]]');
|
||||
});
|
||||
|
||||
it('should not let user change admin\'s password', async function () {
|
||||
const adminUid = await User.create({ username: 'adminpwdchange', password: 'admin1234' });
|
||||
await groups.join('administrators', adminUid);
|
||||
const uid = await User.create({ username: 'changeadminpwd2', password: '123456' });
|
||||
|
||||
let err;
|
||||
try {
|
||||
await socketUser.changePassword({ uid: uid }, { uid: adminUid, newPassword: '654321', currentPassword: '123456' });
|
||||
} catch (_err) {
|
||||
err = _err;
|
||||
}
|
||||
assert.equal(err.message, '[[user:change_password_error_privileges]]');
|
||||
});
|
||||
|
||||
it('should let admin change another users password', async function () {
|
||||
const adminUid = await User.create({ username: 'adminpwdchange2', password: 'admin1234' });
|
||||
await groups.join('administrators', adminUid);
|
||||
const uid = await User.create({ username: 'forgotmypassword', password: '123456' });
|
||||
|
||||
await socketUser.changePassword({ uid: adminUid }, { uid: uid, newPassword: '654321' });
|
||||
const correct = await User.isPasswordCorrect(uid, '654321', '127.0.0.1');
|
||||
assert(correct);
|
||||
});
|
||||
|
||||
it('should change username', function (done) {
|
||||
socketUser.changeUsernameEmail({ uid: uid }, { uid: uid, username: 'updatedAgain', password: '123456' }, function (err) {
|
||||
assert.ifError(err);
|
||||
|
||||
Reference in New Issue
Block a user