From a02dacdc665d94e26e7dc7eab1587e5f4d1592a6 Mon Sep 17 00:00:00 2001 From: Ihar Tsykala Date: Thu, 28 Nov 2024 20:57:27 +0500 Subject: [PATCH] fix: cache user by id when user is not exist (#4420) Co-authored-by: Ihar --- api-gateway/src/helpers/interceptors/utils/hash.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-gateway/src/helpers/interceptors/utils/hash.ts b/api-gateway/src/helpers/interceptors/utils/hash.ts index 0c14e7029..637911ee6 100644 --- a/api-gateway/src/helpers/interceptors/utils/hash.ts +++ b/api-gateway/src/helpers/interceptors/utils/hash.ts @@ -4,5 +4,5 @@ import crypto from 'crypto'; import {IAuthUser} from '@guardian/common'; export function getHash(user: IAuthUser | null): string { - return crypto.createHash('md5').update(JSON.stringify(user.id ?? 'anonymous')).digest('hex'); + return crypto.createHash('md5').update(JSON.stringify(user?.id ?? 'anonymous')).digest('hex'); }