mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: always import avatars during SSO if they are missing
This commit is contained in:
parent
b9801d2e26
commit
33578a2c17
2 changed files with 18 additions and 3 deletions
|
@ -145,11 +145,16 @@ class DiscourseSingleSignOn < SingleSignOn
|
|||
user.name = name || User.suggest_name(username.blank? ? email : username)
|
||||
end
|
||||
|
||||
if (SiteSetting.sso_overrides_avatar && avatar_url.present? && (
|
||||
sso_record.external_avatar_url != avatar_url)) || avatar_force_update
|
||||
avatar_missing = user.uploaded_avatar_id.nil? || !Upload.exists?(user.uploaded_avatar_id)
|
||||
|
||||
if (avatar_missing || avatar_force_update || SiteSetting.sso_overrides_avatar) && avatar_url.present?
|
||||
|
||||
avatar_changed = sso_record.external_avatar_url != avatar_url
|
||||
|
||||
if avatar_force_update || avatar_changed || avatar_missing
|
||||
UserAvatar.import_url_for_user(avatar_url, user)
|
||||
end
|
||||
end
|
||||
|
||||
# change external attributes for sso record
|
||||
sso_record.external_username = username
|
||||
|
|
|
@ -294,6 +294,16 @@ describe DiscourseSingleSignOn do
|
|||
# initial creation ...
|
||||
expect(avatar_id).to_not eq(nil)
|
||||
|
||||
# junk avatar id should be updated
|
||||
old_id = user.uploaded_avatar_id
|
||||
Upload.destroy(old_id)
|
||||
|
||||
user = sso.lookup_or_create_user(ip_address)
|
||||
avatar_id = user.uploaded_avatar_id
|
||||
|
||||
expect(avatar_id).to_not eq(nil)
|
||||
expect(old_id).to_not eq(avatar_id)
|
||||
|
||||
FileHelper.stubs(:download) { raise "should not be called" }
|
||||
sso.avatar_url = "https://some.new/avatar.png"
|
||||
user = sso.lookup_or_create_user(ip_address)
|
||||
|
|
Loading…
Reference in a new issue