From f4043e6db87281f6f395c26c42a3a49e647dbc5f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 26 Feb 2021 16:48:55 +0100 Subject: [PATCH] Fix openid role parsing --- peertube-plugin-auth-openid-connect/main.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/peertube-plugin-auth-openid-connect/main.js b/peertube-plugin-auth-openid-connect/main.js index 8fad0c6..0a13a81 100644 --- a/peertube-plugin-auth-openid-connect/main.js +++ b/peertube-plugin-auth-openid-connect/main.js @@ -256,10 +256,14 @@ async function handleCb (peertubeHelpers, settingsManager, req, res) { let role if (settings['role-property']) { - if (Array.isArray(settings['role-property'])){ - role = parseInt('' + userInfo[settings['role-property']][0], 10); - } else { - role = parseInt('' + userInfo[settings['role-property']], 10) + let roleToParse = userInfo[settings['role-property']] + if (Array.isArray(roleToParse)) roleToParse = roleToParse[0] + + role = parseInt('' + roleToParse, 10) + + if (isNaN(role)) { + logger.error('Cannot load role ' + roleToParse + ' from OpenID: not a number.') + role = null } }