1
0
Fork 0
forked from svrjs/svrjs

Make the improvement consistent with password verification function

This commit is contained in:
Dorian Niemiec 2024-03-17 10:20:00 +01:00
parent 32a92804fa
commit c85df7cd26

12
svr.js
View file

@ -4651,10 +4651,10 @@ if (!cluster.isPrimary) {
var scryptCount = 0; var scryptCount = 0;
if (!authcode.userList || authcode.userList.indexOf(username) > -1) { if (!authcode.userList || authcode.userList.indexOf(username) > -1) {
usernameMatch = users.filter(function (entry) { usernameMatch = users.filter(function (entry) {
if(entry.pbkdf2) { if(entry.scrypt) {
pbkdf2Count++;
} else if(entry.scrypt) {
scryptCount++; scryptCount++;
} else if(entry.pbkdf2) {
pbkdf2Count++;
} else { } else {
sha256Count++; sha256Count++;
} }
@ -4669,10 +4669,10 @@ if (!cluster.isPrimary) {
salt: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0" salt: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0"
}; };
if (!process.isBun) { if (!process.isBun) {
if (pbkdf2Count > sha256Count && pbkdf2Count > scryptCount) { if (scryptCount > sha256Count && scryptCount > pbkdf2Count) {
fakeCredentials.pbkdf2 = true;
} else if (scryptCount > sha256Count) {
fakeCredentials.scrypt = true; fakeCredentials.scrypt = true;
} else if (pbkdf2Count > sha256Count) {
fakeCredentials.pbkdf2 = true;
} }
} }
usernameMatch.push(fakeCredentials); usernameMatch.push(fakeCredentials);