Skip to content

Commit b5a9f16

Browse files
authored
Merge pull request #351 from DigitalCurationCentre/vyruss/bugfixes
Vyruss/bugfixes
2 parents 758a586 + 4770488 commit b5a9f16

File tree

11 files changed

+44
-19
lines changed

11 files changed

+44
-19
lines changed

app/controllers/application_controller.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,15 @@ def errors_to_s(obj)
106106
msg
107107
end
108108
end
109+
110+
##
111+
# Sign out of Shibboleth SP local session too.
112+
# -------------------------------------------------------------
113+
def after_sign_out_path_for(resource_or_scope)
114+
if Rails.application.config.shibboleth_enabled
115+
return Rails.application.config.shibboleth_logout_url + root_url
116+
super
117+
end
118+
end
119+
# -------------------------------------------------------------
109120
end

app/controllers/phases_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def edit
5656
end
5757
theme_guidance[title] << {
5858
text: guidance.text,
59-
org: guidance_group.name
59+
org: guidance_group.name + ':'
6060
}
6161
end
6262
end

app/controllers/users/omniauth_callbacks_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def handle_omniauth(scheme)
6161
end
6262
# -------------------------------------------------------------
6363

64+
6465
def failure
6566
redirect_to root_path
6667
end

app/views/devise/registrations/_external_identifier.html.erb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<div class="user-identifier"
2-
style="background-image: url(<%= "#{scheme.logo_url}" %>); background-size: 16px;">
3-
1+
<div>
42
<% if id.nil? || id.identifier == '' %>
53
<%= link_to "#{_("Create or Link your #{scheme.description} ID")}",
64
Rails.application.routes.url_helpers.send(
@@ -15,9 +13,9 @@
1513
<%= link_to "#{_("Your account has been linked to #{scheme.description}.")}", "#{scheme.user_landing_url}/#{id.identifier}", target: '_blank',
1614
title: t("identifier_schemes.schemes.#{scheme.name}.connect_tooltip", default: "") %>
1715
<% end %>
18-
<%= link_to image_tag('remove.png', height: '16px', width: '16px'),
16+
<%= link_to '<i class="fa fa-fw fa-times-circle" aria-hidden="false"></i>'.html_safe,
1917
destroy_user_identifier_path(id), method: :delete,
2018
title: _("Unlink your account from #{scheme.description}. You can link again at any time."),
21-
data: {confirm: _("Are you sure you want to unlink your #{scheme.description} ID?")} %>
19+
data: {confirm: _("Are you sure you want to unlink #{scheme.description} ID?")} %>
2220
<% end %>
2321
</div>

app/views/devise/registrations/edit.html.erb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@
6363

6464
<% @identifier_schemes.each do |scheme| %>
6565
<div>
66-
<label><%= scheme.name %></label>
67-
<div class="identifier-scheme identifier-scheme-indent">
66+
<label>
67+
<% if scheme.logo_url.nil? %>
68+
<i class="fa fa-user" title="<%= scheme.name %>" aria-hidden="true" style="font-size:16px; width:16px; text-align:center;"></i>
69+
<% else %>
70+
<img title="<%= scheme.name %>" src=<%= "#{scheme.logo_url}" %> size="16px" />
71+
<% end %>
72+
</label>
73+
<div class="identifier-scheme">
6874
<%= render partial: 'external_identifier',
6975
locals: {scheme: scheme,
7076
id: current_user.identifier_for(scheme)} %>

config/application.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ class Application < Rails::Application
9191

9292
# Enable shibboleth as an alternative authentication method
9393
# Requires server configuration and omniauth shibboleth provider configuration
94-
# See config/initializers/omniauth.rb
94+
# See config/initializers/devise.rb
9595
config.shibboleth_enabled = true
9696

97-
# Absolute path to Shibboleth SSO Login
98-
config.shibboleth_login = '/Shibboleth.sso/Login'
99-
97+
# Relative path to Shibboleth SSO Logout
98+
config.shibboleth_logout_url = '/Shibboleth.sso/Logout?return='
99+
100100
# Active Record will no longer suppress errors raised in after_rollback or after_commit
101101
# in the next version. Devise appears to be using those callbacks.
102102
# To accept the new behaviour use 'true' otherwise use 'false'

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# fix for activeadmin signout bug
4848
devise_scope :user do
49-
get '/users/sign_out' => 'devise/sessions#destroy'
49+
delete '/users/sign_out' => 'devise/sessions#destroy'
5050
end
5151

5252
delete '/users/identifiers/:id', to: 'user_identifiers#destroy', as: 'destroy_user_identifier'

db/seeds.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
{name: 'orcid', description: 'ORCID', active: true,
99
logo_url:'http://orcid.org/sites/default/files/images/orcid_16x16.png',
1010
user_landing_url:'https://orcid.org' },
11-
{name: 'shibboleth', description: 'Shibboleth', active: true}
11+
{name: 'shibboleth', description: 'your institutional credentials', active: true,
12+
},
1213
]
1314
identifier_schemes.map{ |is| IdentifierScheme.create!(is) if IdentifierScheme.find_by(name: is[:name]).nil? }
1415

test/functional/sessions_controller_test.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
5353
delete destroy_user_session_path
5454
assert_equal nil, session[:locale], "expected the locale to have been deleted from the session"
5555
assert_response :redirect
56-
assert_redirected_to root_path
56+
if Rails.application.config.shibboleth_enabled
57+
assert_redirected_to Rails.application.config.shibboleth_logout_url + root_url
58+
else
59+
assert_redirected_to root_path
60+
end
5761
end
5862

5963
end

test/functional/users/omniauth_callbacks_controller_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class OmniauthCallbacksControllerTest < ActionDispatch::IntegrationTest
5050

5151
### Until ORCID login becomes supported.
5252
if scheme.name == 'shibboleth'
53-
assert [I18n.t('devise.omniauth_callbacks.user.success').gsub('%{kind}', scheme.name).downcase,
54-
I18n.t('devise.omniauth_callbacks.success').gsub('%{kind}', scheme.name).downcase].include?(flash[:notice].downcase), "Expected a success message when simulating a valid callback from #{scheme.name}"
53+
assert [I18n.t('devise.omniauth_callbacks.user.success').gsub('%{kind}', scheme.description).downcase,
54+
I18n.t('devise.omniauth_callbacks.success').gsub('%{kind}', scheme.description).downcase].include?(flash[:notice].downcase), "Expected a success message when simulating a valid callback from #{scheme.name}"
5555
assert @response.redirect_url.include?(root_url), "Expected a redirect to the root page, #{root_url}, when omniauth returns with a valid identifier!"
5656
else
5757
assert_equal I18n.t('identifier_schemes.new_login_success'), flash[:notice], "Expected a success message when simulating a valid callback from #{scheme.name}"

0 commit comments

Comments
 (0)