Unverified Commit 31a18c8a authored by Mirko Iannella's avatar Mirko Iannella Committed by GitHub

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.
parent 23e34030
...@@ -177,6 +177,8 @@ module.exports = class User extends Model { ...@@ -177,6 +177,8 @@ module.exports = class User extends Model {
if (_.isArray(profile.emails)) { if (_.isArray(profile.emails)) {
const e = _.find(profile.emails, ['primary', true]) const e = _.find(profile.emails, ['primary', true])
primaryEmail = (e) ? e.value : _.first(profile.emails).value 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) { } else if (_.isString(profile.email) && profile.email.length > 5) {
primaryEmail = profile.email primaryEmail = profile.email
} else if (_.isString(profile.mail) && profile.mail.length > 5) { } else if (_.isString(profile.mail) && profile.mail.length > 5) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment