mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04:00
Merge pull request #1955 from hedgedoc/v1/fix-oauth2-avatars
This commit is contained in:
commit
c59a69da87
5 changed files with 18 additions and 6 deletions
|
@ -37,11 +37,11 @@ exports.generateAvatarURL = function (name, email = '', big = true) {
|
||||||
const hexDigest = hash.digest('hex')
|
const hexDigest = hash.digest('hex')
|
||||||
|
|
||||||
if (email !== '' && config.allowGravatar) {
|
if (email !== '' && config.allowGravatar) {
|
||||||
photo = 'https://cdn.libravatar.org/avatar/' + hexDigest
|
photo = `https://cdn.libravatar.org/avatar/${hexDigest}?default=identicon`
|
||||||
if (big) {
|
if (big) {
|
||||||
photo += '?s=400'
|
photo += '&s=400'
|
||||||
} else {
|
} else {
|
||||||
photo += '?s=96'
|
photo += '&s=96'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || hexDigest) + '/avatar.svg'
|
photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || hexDigest) + '/avatar.svg'
|
||||||
|
|
|
@ -133,6 +133,10 @@ module.exports = function (sequelize, DataTypes) {
|
||||||
photo = generateAvatarURL(profile.username, profile.emails[0], bigger)
|
photo = generateAvatarURL(profile.username, profile.emails[0], bigger)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
if (profile.emails && profile.emails.length > 0) {
|
||||||
|
photo = generateAvatarURL(profile.username, profile.emails[0])
|
||||||
|
break
|
||||||
|
}
|
||||||
photo = generateAvatarURL(profile.username)
|
photo = generateAvatarURL(profile.username)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ function parseProfile (data) {
|
||||||
id: id || username,
|
id: id || username,
|
||||||
username: username,
|
username: username,
|
||||||
displayName: displayName,
|
displayName: displayName,
|
||||||
email: email
|
emails: email ? [email] : []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
# Release Notes
|
# Release Notes
|
||||||
|
|
||||||
|
## UNRELEASED
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
- Fix error that Libravatar user avatars were not shown when using OAuth2 login
|
||||||
|
|
||||||
|
### Enhancements
|
||||||
|
- Libravatar avatars render as ident-icons when no avatar image was uploaded to Libravatar or Gravatar
|
||||||
|
|
||||||
## <i class="fa fa-tag"></i> 1.9.2 <i class="fa fa-calendar-o"></i> 2021-12-03
|
## <i class="fa fa-tag"></i> 1.9.2 <i class="fa fa-calendar-o"></i> 2021-12-03
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe('generateAvatarURL() gravatar enabled', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return correct urls', function () {
|
it('should return correct urls', function () {
|
||||||
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels', 'hello@dsprenkels.com', true), 'https://cdn.libravatar.org/avatar/d41b5f3508cc3f31865566a47dd0336b?s=400')
|
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels', 'hello@dsprenkels.com', true), 'https://cdn.libravatar.org/avatar/d41b5f3508cc3f31865566a47dd0336b?default=identicon&s=400')
|
||||||
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels', 'hello@dsprenkels.com', false), 'https://cdn.libravatar.org/avatar/d41b5f3508cc3f31865566a47dd0336b?s=96')
|
assert.strictEqual(avatars.generateAvatarURL('Daan Sprenkels', 'hello@dsprenkels.com', false), 'https://cdn.libravatar.org/avatar/d41b5f3508cc3f31865566a47dd0336b?default=identicon&s=96')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return correct urls for names with spaces', function () {
|
it('should return correct urls for names with spaces', function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue