summaryrefslogtreecommitdiff
path: root/app/models/concerns/avatarable.rb
diff options
context:
space:
mode:
authorMicaƫl Bergeron <mbergeron@gitlab.com>2018-04-23 16:59:53 +0000
committerJohn Northrup <john@gitlab.com>2018-04-23 16:59:53 +0000
commit741f333d23cd09de328c9f4035c16210cb97aa10 (patch)
tree7d7d064ad4b16848bd82a1c26876e5a4292151a3 /app/models/concerns/avatarable.rb
parentc0eabb84f57aed587589839136dadff01836e888 (diff)
downloadgitlab-ce-741f333d23cd09de328c9f4035c16210cb97aa10.tar.gz
Resolve "Avatar URLs are wrong when using a CDN path and Object Storage"
Diffstat (limited to 'app/models/concerns/avatarable.rb')
-rw-r--r--app/models/concerns/avatarable.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/concerns/avatarable.rb b/app/models/concerns/avatarable.rb
index 7677891b9ce..13246a774e3 100644
--- a/app/models/concerns/avatarable.rb
+++ b/app/models/concerns/avatarable.rb
@@ -31,12 +31,13 @@ module Avatarable
asset_host = ActionController::Base.asset_host
use_asset_host = asset_host.present?
+ use_authentication = respond_to?(:public?) && !public?
# Avatars for private and internal groups and projects require authentication to be viewed,
# which means they can only be served by Rails, on the regular GitLab host.
# If an asset host is configured, we need to return the fully qualified URL
# instead of only the avatar path, so that Rails doesn't prefix it with the asset host.
- if use_asset_host && respond_to?(:public?) && !public?
+ if use_asset_host && use_authentication
use_asset_host = false
only_path = false
end
@@ -49,6 +50,6 @@ module Avatarable
url_base << gitlab_config.relative_url_root
end
- url_base + avatar.url
+ url_base + avatar.local_url
end
end