Skip to content

Commit bf910be

Browse files
committed
1 parent 4ecf0ef commit bf910be

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/backend/middlewares/user/AuthenticationMWs.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,10 @@ export class AuthenticationMWs {
249249
if (
250250
typeof req.body === 'undefined' ||
251251
typeof req.body.loginCredential === 'undefined' ||
252-
typeof req.body.loginCredential.username === 'undefined' ||
253-
typeof req.body.loginCredential.password === 'undefined'
252+
typeof req.body.loginCredential.username !== 'string' ||
253+
typeof req.body.loginCredential.password !== 'string' ||
254+
req.body.loginCredential.username.length === 0 ||
255+
req.body.loginCredential.password.length === 0
254256
) {
255257
Logger.warn(LOG_TAG, 'Failed login from IP `' + req.ip + '` no user or password provided');
256258
return next(

src/backend/model/database/UserManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ export class UserManager {
1212

1313
public async findOne(filter: FindOptionsWhere<UserEntity>): Promise<UserEntity> {
1414
const connection = await SQLConnection.getConnection();
15+
const verifyPassword = typeof filter.password == 'string';
1516
const pass = filter.password as string;
1617
delete filter.password;
1718
const user = await connection.getRepository(UserEntity).findOneBy(filter);
1819

19-
if (pass && !PasswordHelper.comparePassword(pass, user.password)) {
20+
if (verifyPassword && !PasswordHelper.comparePassword(pass, user.password)) {
2021
throw new Error('No entry found');
2122
}
2223
return user;

0 commit comments

Comments
 (0)