From 6227045958934c8865258aa9b521cbfe34350c62 Mon Sep 17 00:00:00 2001 From: Arne Gnisa Date: Fri, 22 Sep 2023 12:02:48 +0200 Subject: [PATCH] N21-1269 review fixes --- controllers/oauth2.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/oauth2.js b/controllers/oauth2.js index c7b2383580..aadc175442 100644 --- a/controllers/oauth2.js +++ b/controllers/oauth2.js @@ -155,8 +155,10 @@ router.get('/username/:pseudonym', async (req, res, next) => { qs: { id: pseudonymResponse.userId }, $limit: 1, }); - completeName = `${userResponse.data[0].firstName} ${userResponse.data[0].lastName}`; - shortName = `${userResponse.data[0].firstName} ${userResponse.data[0].lastName.charAt(0)}.`; + if (userResponse.data?.length === 1) { + completeName = `${userResponse.data[0].firstName} ${userResponse.data[0].lastName}`; + shortName = `${userResponse.data[0].firstName} ${userResponse.data[0].lastName.charAt(0)}.`; + } } else { const feathersPseudonymResponse = await api(req) .get('/pseudonym', {