From 5c1252801eaecbd2ef4c3a5aa4fb16111ec39bd9 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 20 Oct 2025 21:14:53 +0200 Subject: [PATCH] Fix: Null-safe access to rightType.title in menu endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Verwende Optional Chaining (?.) für ur.rightType.title - Filtere null/undefined Werte aus rights Array - Behebt: Cannot read properties of null (reading 'title') --- backend/controllers/navigationController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/controllers/navigationController.js b/backend/controllers/navigationController.js index 5485fcb..cdc8379 100644 --- a/backend/controllers/navigationController.js +++ b/backend/controllers/navigationController.js @@ -359,7 +359,7 @@ class NavigationController { }); const birthDate = userBirthdateParams.length > 0 ? userBirthdateParams[0].value : (new Date()).toDateString(); const age = this.calculateAge(birthDate); - const rights = userRights.map(ur => ur.rightType.title); + const rights = userRights.map(ur => ur.rightType?.title).filter(Boolean); const filteredMenu = await this.filterMenu(menuStructure, rights, age, user.id); res.status(200).json(filteredMenu); } catch (error) {