mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 16:48:03 +08:00
Fix bug when sso_overrides_avatar is true but no avatar_url is passed
If a user has a current avatar, and sso_overrides_avatar is true, but no avatar_url is passed in the sso attributes, the current code errors, as it tries to parse a nil as a URL. It seems to me valid that a third party system may not pass an avatar_url in some cases (e.g. avatars may not be mandatory, so not all users may have them) This might warrant a discussion about what should happen in this case; maybe the current avatar in discourse should be removed? This branch merely stops the login process erroring.
This commit is contained in:
@ -125,10 +125,11 @@ class DiscourseSingleSignOn < SingleSignOn
|
||||
user.name = User.suggest_name(name || username || email)
|
||||
end
|
||||
|
||||
if SiteSetting.sso_overrides_avatar && (
|
||||
if SiteSetting.sso_overrides_avatar && avatar_url.present? && (
|
||||
avatar_force_update == "true" ||
|
||||
avatar_force_update.to_i != 0 ||
|
||||
sso_record.external_avatar_url != avatar_url)
|
||||
|
||||
begin
|
||||
tempfile = FileHelper.download(avatar_url, 1.megabyte, "sso-avatar", true)
|
||||
|
||||
|
Reference in New Issue
Block a user