From 31a18c8a67ef68ba0221fa57d79965c1ad478289 Mon Sep 17 00:00:00 2001 From: Mirko Iannella Date: Sat, 3 Oct 2020 22:23:58 +0200 Subject: [PATCH] fix: check for email array during processProfile (#2515) In our setup (based on yunohost) the profile.email field could be either a string (and that was properly handled) or an array. This code adds support for the case where it is an array. --- server/models/users.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/models/users.js b/server/models/users.js index 28f3919e..86bfbc5d 100644 --- a/server/models/users.js +++ b/server/models/users.js @@ -177,6 +177,8 @@ module.exports = class User extends Model { if (_.isArray(profile.emails)) { const e = _.find(profile.emails, ['primary', true]) primaryEmail = (e) ? e.value : _.first(profile.emails).value + } else if (_.isArray(profile.email)) { + primaryEmail = _.first(_.flattenDeep([profile.email])); } else if (_.isString(profile.email) && profile.email.length > 5) { primaryEmail = profile.email } else if (_.isString(profile.mail) && profile.mail.length > 5) {