Skip to content

Commit

Permalink
Introduce candidate to wrong email address page
Browse files Browse the repository at this point in the history
If a candidate tries to login with the candidate email address and they
have a one login email address that is different from the candidate
email address. We will not allow the user to login, with one login.

We will redirect the user to the wrong_email_address page.

Previously we would have redirected the user to 500 error page. This
page is intended to have more content helping the candidate to unstuck
themselves rather than contacting support
  • Loading branch information
CatalinVoineag committed Jan 21, 2025
1 parent d2d4abc commit 5eeb2c7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/controllers/candidate_interface/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module CandidateInterface
class ErrorsController < CandidateInterfaceController
skip_before_action :verify_authenticity_token
skip_before_action :authenticate_candidate!
allow_unauthenticated_access only: [:wrong_email_address]

def account_locked
render 'errors/account_locked', status: :forbidden, formats: :html
Expand All @@ -10,5 +11,9 @@ def account_locked
def not_found
render 'errors/not_found', status: :not_found, formats: :html
end

def wrong_email_address
render 'errors/wrong_email_address_used_for_candidate', status: :forbidden, formats: :html
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/one_login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def sign_out
def sign_out_complete
if session[:session_error_id].present?
reset_session
redirect_to internal_server_error_path
redirect_to candidate_interface_wrong_email_address_path
else
redirect_to candidate_interface_create_account_or_sign_in_path
end
Expand Down
14 changes: 14 additions & 0 deletions app/views/errors/wrong_email_address_used_for_candidate.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%= content_for :title, t('page_titles.there_is_a_problem') %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l"><%= t('page_titles.there_is_a_problem') %></h1>
<p class="govuk-body">
You should use the email address you use for GOV.UK One Login to sign in to Apply for teacher training.
</p>
<p class="govuk-body">
If you have any questions, please email us at
<a class="govuk-link" href="mailto:[email protected]">[email protected]</a>
</p>
</div>
</div>
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ en:
get_your_details_back: Get your details back
dismiss: Dismiss
page_titles:
there_is_a_problem: There is a problem
account_recovery: Enter the code we sent to %{email}
account_recovery_resend_email: Enter the new code we sent to %{email}
account_recovery_request: Get your account details back
Expand Down
1 change: 1 addition & 0 deletions config/routes/candidate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@
end

get '/account-locked', to: 'errors#account_locked'
get '/wrong-email-address', to: 'errors#wrong_email_address'

get '/about-the-teacher-training-application-process', to: 'guidance#index', as: :guidance

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/one_login_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"One login session error, check session_error record #{SessionError.last.id}",
level: :error,
)
expect(response).to redirect_to(internal_server_error_path)
expect(response).to redirect_to(candidate_interface_wrong_email_address_path)
end
end

Expand Down

0 comments on commit 5eeb2c7

Please sign in to comment.