mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-22 23:50:47 +02:00
fix: login with weak password
This commit is contained in:
@@ -127,7 +127,7 @@ module.exports = function (User) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
User.isPasswordValid = function (password, minStrength) {
|
User.isPasswordValid = function (password, minStrength) {
|
||||||
minStrength = minStrength || meta.config.minimumPasswordStrength;
|
minStrength = (minStrength || minStrength === 0) ? minStrength : meta.config.minimumPasswordStrength;
|
||||||
|
|
||||||
// Sanity checks: Checks if defined and is string
|
// Sanity checks: Checks if defined and is string
|
||||||
if (!password || !utils.isPasswordValid(password)) {
|
if (!password || !utils.isPasswordValid(password)) {
|
||||||
|
|||||||
15
test/user.js
15
test/user.js
@@ -1519,7 +1519,7 @@ describe('User', function () {
|
|||||||
|
|
||||||
it('should save user settings', function (done) {
|
it('should save user settings', function (done) {
|
||||||
var data = {
|
var data = {
|
||||||
uid: 1,
|
uid: testUid,
|
||||||
settings: {
|
settings: {
|
||||||
bootswatchSkin: 'default',
|
bootswatchSkin: 'default',
|
||||||
homePageRoute: 'none',
|
homePageRoute: 'none',
|
||||||
@@ -2191,4 +2191,17 @@ describe('User', function () {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow user to login even if password is weak', function (done) {
|
||||||
|
User.create({ username: 'weakpwd', password: '123456' }, function (err) {
|
||||||
|
assert.ifError(err);
|
||||||
|
const oldValue = meta.config.minimumPasswordStrength;
|
||||||
|
meta.config.minimumPasswordStrength = 3;
|
||||||
|
helpers.loginUser('weakpwd', '123456', function (err, jar, csrfs_token) {
|
||||||
|
assert.ifError(err);
|
||||||
|
meta.config.minimumPasswordStrength = oldValue;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user