Skip to content

Commit

Permalink
Merge pull request #3106 from DFE-Digital/one-login-fe-failure
Browse files Browse the repository at this point in the history
[LUPEYALPHA-869] [LUPEYALPHA-870] One login FE failure
  • Loading branch information
asmega authored Aug 20, 2024
2 parents 982e46b + d437f1e commit 90387d9
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/controllers/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ def callback
end

def failure
render layout: false
case params[:strategy]
when "onelogin"
render OneLogin::FailureHandler.new(
message: params[:message],
origin: params[:origin],
answers: journey_session.answers
).template
else
render layout: false
end
end

def onelogin
Expand Down
23 changes: 23 additions & 0 deletions app/models/one_login/failure_handler.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class OneLogin::FailureHandler
attr_reader :message, :origin, :answers

def initialize(message:, origin:, answers:)
@message = message
@origin = origin
@answers = answers
end

def template
if !answers.logged_in_with_onelogin
"#{journey::VIEW_PATH}_auth_failure"
elsif answers.logged_in_with_onelogin
"#{journey::VIEW_PATH}_idv_failure"
end
end

private

def journey
Journeys::FurtherEducationPayments
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<% content_for(:page_title, page_title("Sorry, there is a problem with the service", journey: current_journey_routing_name, show_error: false)) %>

<% @backlink_path = claim_path(journey: current_journey_routing_name, slug: "sign-in") %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">
Sorry, there is a problem with the service
</h1>

<p class="govuk-body">
Try again later.
</p>

<p class="govuk-body">
Email <%= govuk_link_to "[email protected]", "mailto:[email protected]" %> if you need help.
</p>

<%= govuk_button_link_to "Try again", claim_path(journey: current_journey_routing_name, slug: "sign-in") %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<% content_for(:page_title, page_title("We cannot progress your application", journey: current_journey_routing_name, show_error: false)) %>

<% @backlink_path = claim_path(journey: current_journey_routing_name, slug: "sign-in") %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">
We cannot progress your application
</h1>

<p class="govuk-body">
You need to be able to prove your identity in GOV.UK One Login to continue your application. You can find more information about <%= govuk_link_to "proving your identity", "https://www.gov.uk/using-your-gov-uk-one-login" %> on GOV.UK.
</p>

<p class="govuk-body">
If you have any queries about the application process, contact us at <%= govuk_link_to t("further_education_payments.support_email_address"), "mailto:#{t("further_education_payments.support_email_address")}" %>.
</p>
</div>
</div>
32 changes: 32 additions & 0 deletions spec/requests/omniauth_callbacks_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,36 @@ def set_mock_auth(trn)
end
end
end

describe "#failure" do
context "FE journey" do
before do
create(:journey_configuration, :further_education_payments)
end

context "when onelogin auth fail" do
it "renders problem with service page" do
get "/further-education-payments/claim"

get "/auth/failure?message=access_denied&origin=http%3A%2F%2Flocalhost%3A3000%2Ffurther-education-payments%2Fsign-in&strategy=onelogin"

expect(response.body).to include("Sorry, there is a problem with the service")
end
end

context "when onelogin idv fail" do
it "renders cannot progress page" do
get "/further-education-payments/claim"

journey_session = Journeys::FurtherEducationPayments::Session.last
journey_session.answers.logged_in_with_onelogin = true
journey_session.save!

get "/auth/failure?message=access_denied&origin=http%3A%2F%2Flocalhost%3A3000%2Ffurther-education-payments%2Fsign-in&strategy=onelogin"

expect(response.body).to include("We cannot progress your application")
end
end
end
end
end

0 comments on commit 90387d9

Please sign in to comment.