From 1f7f7f609c3978e613702ab493e20cde5838548f Mon Sep 17 00:00:00 2001 From: Bastien Le Querrec Date: Sat, 8 Aug 2020 14:40:34 +0200 Subject: [PATCH] if returned value for role is an array, use first element This improves Keycloak compatibility as if Multivalued is set to false in Mappers, return value will still be an array. --- peertube-plugin-auth-openid-connect/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/peertube-plugin-auth-openid-connect/main.js b/peertube-plugin-auth-openid-connect/main.js index 68a6fc2..7e8ccc6 100644 --- a/peertube-plugin-auth-openid-connect/main.js +++ b/peertube-plugin-auth-openid-connect/main.js @@ -239,7 +239,11 @@ async function handleCb (peertubeHelpers, settingsManager, req, res) { let role if (settings['role-property']) { - role = parseInt('' + userInfo[settings['role-property']], 10) + if (Array.isArray(settings['role-property'])){ + role = parseInt('' + userInfo[settings['role-property']][0], 10); + } else { + role = parseInt('' + userInfo[settings['role-property']], 10) + } } let displayName