File tree Expand file tree Collapse file tree 5 files changed +38
-2
lines changed
Expand file tree Collapse file tree 5 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -11,4 +11,8 @@ def space_feature_options
1111 [ t ( "features.#{ f } .short" ) , f ]
1212 end
1313 end
14+
15+ def space_supports_omniauth? ( space = current_space )
16+ space . nil? || space . default? || space . is_subdomain? ( TeSS ::Config . base_uri . domain )
17+ end
1418end
Original file line number Diff line number Diff line change 99 < strong > Log In</ strong > < span class ="caret "> </ span >
1010 </ a >
1111 < ul class ="dropdown-menu dropdown-menu-right ">
12- <% Devise . omniauth_configs . each do |provider , config | -%>
13- < li class ="dropdown-item "> <%= omniauth_login_link ( provider , config ) %> </ li >
12+ <% if space_supports_omniauth? %>
13+ <% Devise . omniauth_configs . each do |provider , config | -%>
14+ < li class ="dropdown-item "> <%= omniauth_login_link ( provider , config ) %> </ li >
15+ <% end %>
1416 <% end %>
1517
1618 < li class ="dropdown-item ">
Original file line number Diff line number Diff line change @@ -170,6 +170,10 @@ def _sentry_dsn
170170 def sentry_enabled?
171171 _sentry_dsn . present? && Rails . env . production?
172172 end
173+
174+ def base_uri
175+ @base_uri ||= Addressable ::URI . parse ( base_url )
176+ end
173177 end
174178
175179 Config = TessConfig . new ( tess_config )
Original file line number Diff line number Diff line change @@ -712,4 +712,26 @@ class StaticControllerTest < ActionController::TestCase
712712 end
713713 end
714714 end
715+
716+ test 'show omniauth login options when on subdomain space' do
717+ space = spaces ( :plants )
718+ space . update! ( host : 'plants.example.com' )
719+ with_host ( space . host ) do
720+ get :home
721+ assert_select 'ul.user-options.nav.navbar-nav.navbar-right' do
722+ assert_select "a[href=\" /users/auth/oidc?space_id=#{ space . id } \" ]" , count : 1
723+ end
724+ end
725+ end
726+
727+ test 'do not show omniauth login options when on non-subdomain space' do
728+ space = spaces ( :plants )
729+ space . update! ( host : 'other-host.com' )
730+ with_host ( space . host ) do
731+ get :home
732+ assert_select 'ul.user-options.nav.navbar-nav.navbar-right' do
733+ assert_select "a[href=\" /users/auth/oidc?space_id=#{ space . id } \" ]" , count : 0
734+ end
735+ end
736+ end
715737end
Original file line number Diff line number Diff line change @@ -27,4 +27,8 @@ class ConfigTest < ActiveSupport::TestCase
2727 end
2828 assert_equal exp , TeSS ::Config . redis_url
2929 end
30+
31+ test 'base_uri' do
32+ assert_equal 'example.com' , TeSS ::Config . base_uri . domain
33+ end
3034end
You can’t perform that action at this time.
0 commit comments