Skip to content

Commit

Permalink
Fixup logout so that it doesn't crash with a 403
Browse files Browse the repository at this point in the history
  • Loading branch information
starswan committed Jul 14, 2021
1 parent 5a65ab5 commit 771ac0c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion app/models/signon_identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ def initialize(user, full_name:, logout_url:, organisations:, roles:)

def logout_url(redirect_to: nil)
url = URI.parse(@logout_url)
url.query = { redirect_to: redirect_to }.to_query if redirect_to
if redirect_to
url.query = {
redirect_uri: redirect_to,
client_id: Rails.configuration.nomis_user_oauth_client_id
}.to_query
end

url.to_s
end

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
it 'deletes the current user id from the session and redirects' do
expect(destroy).
to redirect_to(<<-URI.strip_heredoc)
http://example.com/logout?redirect_to=#{CGI.escape(root_url)}
http://example.com/logout?client_id=prison-visits-booking-frontend&redirect_uri=#{CGI.escape(root_url)}
URI
expect(session[:sso_data]).to be_nil
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/signon_identity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
expect(
subject.logout_url(redirect_to: 'https://pvb/loggedout')
).to eq(
'https://example.com/logout?redirect_to=https%3A%2F%2Fpvb%2Floggedout'
'https://example.com/logout?client_id=prison-visits-booking-frontend&redirect_uri=https%3A%2F%2Fpvb%2Floggedout'
)
end
end
Expand Down

0 comments on commit 771ac0c

Please sign in to comment.