Skip to content

Commit c323b42

Browse files
committed
fix: Force false result when comparing against dummy hash for passwordless users
1 parent 72035d7 commit c323b42

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Routers/UsersRouter.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ export class UsersRouter extends ClassesRouter {
127127
user = results[0];
128128
}
129129

130-
const hashedPassword =
131-
typeof user.password === 'string' ? user.password : passwordCrypto.dummyHash;
132-
return passwordCrypto.compare(password, hashedPassword);
130+
const hasStoredPassword =
131+
typeof user.password === 'string' && user.password.length > 0;
132+
const hashedPassword = hasStoredPassword ? user.password : passwordCrypto.dummyHash;
133+
return passwordCrypto
134+
.compare(password, hashedPassword)
135+
.then(correct => (hasStoredPassword ? correct : false));
133136
})
134137
.then(correct => {
135138
isValidPassword = correct;

0 commit comments

Comments
 (0)