Skip to content

Commit ca29f1a

Browse files
committed
fix(sessions): fix null session check in redis session repository
1 parent ce9af59 commit ca29f1a

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"http-status-codes": "^2.3.0",
9595
"ioredis": "^5.3.2",
9696
"jsonwebtoken": "^9.0.2",
97+
"just-is-empty": "^3.4.1",
9798
"luxon": "^3.4.3",
9899
"method-override": "^3.0.0",
99100
"multer": "1.4.5-lts.1",

src/infrastructure/sessions/redis-session.repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Inject } from '@tsed/di';
2+
import isEmpty from 'just-is-empty';
23

34
import { Session } from '@domain/sessions/session';
45
import { SessionRepository } from '@domain/sessions/session.repository';
@@ -27,7 +28,7 @@ class RedisSessionRepository extends RedisBaseRepository<RedisSession> implement
2728
public async findByUuid(uuid: SessionUuid): Promise<Nullable<Session>> {
2829
const cachedSession = await this.connection.hgetall(this.getKeyPrefix(uuid.value));
2930

30-
return cachedSession == null || cachedSession.deletedAt ? null : RedisSessionMapper.toDomainModel(cachedSession);
31+
return isEmpty(cachedSession) || cachedSession.deletedAt ? null : RedisSessionMapper.toDomainModel(cachedSession);
3132
}
3233

3334
public async create(session: Session): Promise<Session> {

0 commit comments

Comments
 (0)