Fix openid role parsing

This commit is contained in:
Chocobozzz 2021-02-26 16:48:55 +01:00
parent 0ea5fe6a01
commit f4043e6db8
No known key found for this signature in database
GPG Key ID: 583A612D890159BE

View File

@ -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
}
}