diff --git a/app/controllers/session_controller.rb b/app/controllers/session_controller.rb index 5a54591a0b0..2d217ce8b16 100644 --- a/app/controllers/session_controller.rb +++ b/app/controllers/session_controller.rb @@ -63,7 +63,8 @@ class SessionController < ApplicationController sso.groups = current_user.groups.pluck(:name).join(",") if current_user.uploaded_avatar.present? - avatar_url = "#{Discourse.store.absolute_base_url}/#{Discourse.store.get_path_for_upload(current_user.uploaded_avatar)}" + base_url = Discourse.store.external? ? "#{Discourse.store.absolute_base_url}/" : Discourse.base_url + avatar_url = "#{base_url}#{Discourse.store.get_path_for_upload(current_user.uploaded_avatar)}" sso.avatar_url = UrlHelper.absolute Discourse.store.cdn_url(avatar_url) end diff --git a/spec/requests/session_controller_spec.rb b/spec/requests/session_controller_spec.rb index 3dfb07c5833..408cb6a3991 100644 --- a/spec/requests/session_controller_spec.rb +++ b/spec/requests/session_controller_spec.rb @@ -630,7 +630,7 @@ RSpec.describe SessionController do expect(sso2.profile_background_url.blank?).to_not eq(true) expect(sso2.card_background_url.blank?).to_not eq(true) - expect(sso2.avatar_url).to start_with(SiteSetting.s3_cdn_url) + expect(sso2.avatar_url).to start_with("#{SiteSetting.s3_cdn_url}/original") expect(sso2.profile_background_url).to start_with(SiteSetting.s3_cdn_url) expect(sso2.card_background_url).to start_with(SiteSetting.s3_cdn_url) end @@ -774,7 +774,7 @@ RSpec.describe SessionController do expect(sso2.profile_background_url.blank?).to_not eq(true) expect(sso2.card_background_url.blank?).to_not eq(true) - expect(sso2.avatar_url).to start_with(Discourse.base_url) + expect(sso2.avatar_url).to start_with("#{Discourse.store.absolute_base_url}/original") expect(sso2.profile_background_url).to start_with(Discourse.base_url) expect(sso2.card_background_url).to start_with(Discourse.base_url) end