From 66c3de90dd4888b69134458b1835ac2fc154f997 Mon Sep 17 00:00:00 2001 From: Oguzcan Kirmemis Date: Thu, 21 Sep 2023 16:26:13 +0200 Subject: [PATCH] Fix incorrect account id parsing in authentication service closes #66 Signed-off-by: Oguzcan Kirmemis --- lib/authService/authenticate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/authService/authenticate.js b/lib/authService/authenticate.js index 58e39d37..f40f74d8 100644 --- a/lib/authService/authenticate.js +++ b/lib/authService/authenticate.js @@ -99,7 +99,7 @@ class Authenticate { // check whether accounts contains only one element and role is device var accounts = decoded_token.accounts; var did = decoded_token.device_id ? decoded_token.device_id : decoded_token.sub; - var accountId = accounts ? accounts[0].id : null; + var accountId = accounts && accounts.length > 0 ? accounts[0].id : null; let realm = getRealm(decoded_token); // put realm/device into the list of accepted topics await this.cache.setValue(realm + "/" + did, "acl", true);