Skip to content

Commit

Permalink
Redirect sign in page
Browse files Browse the repository at this point in the history
  • Loading branch information
richardpattinson committed Jan 10, 2025
1 parent cdb61cc commit 14bf167
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ BYPASS_DSI=true
HOSTING_DOMAIN=http://localhost:3000
HOSTING_ENVIRONMENT=local

CHECK_CHILDRENS_BARRED_LIST_GUIDANCE_URL=https://www.gov.uk/guidance/check-a-teachers-record

DFE_SIGN_IN_API_BASE_URL=https://dev-api.signin.education.gov.uk
DFE_SIGN_IN_API_SECRET=override-locally
DFE_SIGN_IN_API_AUDIENCE=signin.education.gov.uk
Expand Down
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CHECK_CHILDRENS_BARRED_LIST_GUIDANCE_URL=https://www.gov.uk/guidance/check-a-teachers-record
DFE_SIGN_IN_API_BASE_URL=https://dev-api.signin.education.gov.uk
DFE_SIGN_IN_API_SECRET=test
DFE_SIGN_IN_API_AUDIENCE=signin.education.gov.uk
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ gem "govuk_markdown"
# Provide endpoint for server healthchecks
gem "okcomputer"

gem "repost"
# Sentry error reporting
gem "sentry-rails"
gem "sentry-ruby"
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ GEM
regexp_parser (2.9.2)
reline (0.5.9)
io-console (~> 0.5)
repost (0.4.2)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand Down Expand Up @@ -629,6 +630,7 @@ DEPENDENCIES
puma (~> 6.4)
rails (~> 7.1.3)
rails_semantic_logger
repost
rladr
rspec
rspec-rails
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/sign_in_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class SignInController < ApplicationController
before_action :handle_failed_sign_in, if: -> { params[:oauth_failure] == "true" }

def new
if DfESignIn.bypass?
redirect_post "/check-childrens-barred-list/auth/developer/callback", options: { authenticity_token: :auto }
else
redirect_post "/check-childrens-barred-list/auth/dfe", options: { authenticity_token: :auto }
end
end

private
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/sign_out_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SignOutController < ApplicationController
before_action :reset_session

def new
redirect_to sign_in_path
redirect_to ENV.fetch("CHECK_RECORDS_GUIDANCE_URL", "https://www.gov.uk/guidance/check-a-teachers-record"),
allow_other_host: true
end
end
8 changes: 4 additions & 4 deletions spec/support/system/authentication_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ module AuthenticationSteps
def when_i_sign_in_via_dsi(authorised: true, orgs: [organisation], accept_terms_and_conditions: true)
given_dsi_auth_is_mocked(authorised:, orgs:)
when_i_visit_the_sign_in_page
and_click_the_dsi_sign_in_button
and_wait_for_the_page_to_load
and_i_accept_the_terms_and_conditions(accept_terms_and_conditions)
end
alias_method :and_i_am_signed_in_via_dsi, :when_i_sign_in_via_dsi

def when_i_sign_in_as_an_internal_user_via_dsi
given_dsi_auth_is_mocked(authorised: true, internal: true)
when_i_visit_the_sign_in_page
and_click_the_dsi_sign_in_button
and_wait_for_the_page_to_load
and_i_accept_the_terms_and_conditions(true)
end
alias_method :and_i_am_signed_in_as_an_internal_user_via_dsi, :when_i_sign_in_as_an_internal_user_via_dsi
Expand Down Expand Up @@ -96,8 +96,8 @@ def when_i_visit_the_sign_in_page
visit sign_in_path
end

def and_click_the_dsi_sign_in_button
click_button "Start now"
def and_wait_for_the_page_to_load
page.driver.refresh
end

def organisations_endpoint
Expand Down
39 changes: 0 additions & 39 deletions spec/system/user_has_oauth_error_signing_in_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/system/user_signs_out_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def when_i_sign_out
end

def then_i_am_redirected_to_the_sign_in_page
expect(page).to have_button "Start now"
expect(page).to have_current_path(ENV.fetch("CHECK_CHILDRENS_BARRED_LIST_GUIDANCE_URL"))
end
end

0 comments on commit 14bf167

Please sign in to comment.