1
0
Fork 0
mirror of https://github.com/hedgedoc/hedgedoc.git synced 2025-04-17 14:38:52 +00:00

Use libravatar image if email address is defined

We use the attribute `emails` (plural) for email addresses with other auth providers like LDAP or SAML. In case of OAuth2 we used the attribute `email` (singular) which resulted in problems.
Furthermore the OAuth2 strategy fell into the default fallback of the provider switch statement. This statement did not check email addresses but did generate the letter-avatar instantly.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2022-01-07 14:01:32 +01:00
parent fe98f63149
commit 6e983ba5dc
No known key found for this signature in database
GPG key ID: DB99ADDDC5C0AF82
2 changed files with 5 additions and 1 deletions
lib
models
web/auth/oauth2

View file

@ -133,6 +133,10 @@ module.exports = function (sequelize, DataTypes) {
photo = generateAvatarURL(profile.username, profile.emails[0], bigger)
break
default:
if (profile.emails && profile.emails.length > 0) {
photo = generateAvatarURL(profile.username, profile.emails[0])
break
}
photo = generateAvatarURL(profile.username)
break
}

View file

@ -62,7 +62,7 @@ function parseProfile (data) {
id: id || username,
username: username,
displayName: displayName,
email: email
emails: email ? [email] : []
}
}