Skip to content

Commit

Permalink
Clear the session, redirect to the verify url and add new flash[:succ…
Browse files Browse the repository at this point in the history
…ess] in layout
  • Loading branch information
kenfodder committed Sep 4, 2024
1 parent 4290070 commit 31e98f4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
10 changes: 5 additions & 5 deletions app/controllers/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def failure
def sign_out
case current_journey_routing_name
when "further-education-payments-provider"
claim = journey_session.answers.claim
clear_journey_sessions!

flash[:success] = "You have signed out of DfE Sign-in"
redirect_to(
claim_path(
journey: current_journey_routing_name,
slug: "sign-in"
),
notice: "You've been signed out"
Journeys::FurtherEducationPayments::Provider::SlugSequence.verify_claim_url(claim)
)
else
render file: Rails.root.join("public", "404.html"), status: :not_found, layout: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
that you have logged in using the correct one.
</p>

<%= govuk_button_link_to "Sign out", Journeys::FurtherEducationPayments::Provider.sign_out_url %>

<p class="govuk-body">
<p class="govuk-body govuk-!-margin-top-6">
Email <%= govuk_mail_to t("further_education_payments_provider.support_email_address") %>
if you have logged in with the correct organisation and need support.
</p>

<%= govuk_button_link_to "Sign out", Journeys::FurtherEducationPayments::Provider.sign_out_url %>
11 changes: 8 additions & 3 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@

<main class="govuk-main-wrapper app-main-class" id="main-content">
<% flash.each do |name, msg| %>
<div class="govuk-body-l govuk-flash__<%= name %>">
<%= msg %>
</div>
<% if name == "success" %>
<%= govuk_notification_banner(title_text: "Success", success: true) { |nb| nb.with_heading(text: msg) } %>
<% else %>
<div class="govuk-body-l govuk-flash__<%= name %>">
<%= msg %>
</div>
<% end %>
<% end %>

<%= yield %>
</main>
</div>
Expand Down
14 changes: 7 additions & 7 deletions spec/requests/omniauth_callbacks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

RSpec.describe "OmniauthCallbacksControllers", type: :request do
describe "#sign_out" do
let(:claim_id) { "1234-1234-1234-1234" }

before do
answers_with_claim = double(claim: double(id: claim_id))
journey_session_with_answers_and_claim = double(answers: answers_with_claim)
allow_any_instance_of(OmniauthCallbacksController).to receive(:current_journey_routing_name).and_return(journey)
allow_any_instance_of(OmniauthCallbacksController).to receive(:journey_session).and_return(journey_session_with_answers_and_claim)

get auth_sign_out_path(journey: "further-education-payments-provider")
end
Expand All @@ -12,14 +17,9 @@
let(:journey) { Journeys::FurtherEducationPayments::Provider::ROUTING_NAME }

it "redirects to the FE sign-in page with a flash message" do
expect(response).to redirect_to(
claim_path(
journey: "further-education-payments-provider",
slug: "sign-in"
)
)
expect(response).to redirect_to("https://www.example.com/further-education-payments-provider/claim?answers%5Bclaim_id%5D=#{claim_id}")

expect(flash[:notice]).to include("You've been signed out")
expect(flash[:success]).to include("You have signed out of DfE Sign-in")
end
end

Expand Down

0 comments on commit 31e98f4

Please sign in to comment.