diff --git a/app/controllers/base_public_controller.rb b/app/controllers/base_public_controller.rb index 52c68b4efa..2710544073 100644 --- a/app/controllers/base_public_controller.rb +++ b/app/controllers/base_public_controller.rb @@ -1,23 +1,14 @@ class BasePublicController < ApplicationController include DfE::Analytics::Requests - include ClaimSessionTimeout + include SessionManagement include HttpAuthConcern include JourneyConcern - helper_method :claim_timeout_in_minutes before_action :add_view_paths - before_action :end_expired_claim_sessions after_action :update_last_seen_at private - def end_expired_claim_sessions - if claim_session_timed_out? - clear_claim_session - redirect_to timeout_claim_path(current_journey_routing_name) - end - end - def update_last_seen_at session[:last_seen_at] = Time.zone.now end diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb index 42c3917b51..72583a42db 100644 --- a/app/controllers/claims_controller.rb +++ b/app/controllers/claims_controller.rb @@ -1,7 +1,7 @@ class ClaimsController < BasePublicController include PartOfClaimJourney - skip_before_action :send_unstarted_claimants_to_the_start, only: [:new, :create, :timeout] + skip_before_action :send_unstarted_claimants_to_the_start, only: [:new, :create] before_action :initialize_session_slug_history before_action :check_page_is_in_sequence, only: [:show, :update] before_action :update_session_with_current_slug, only: [:update] @@ -14,9 +14,6 @@ class ClaimsController < BasePublicController include FormSubmittable include ClaimsFormCallbacks - def timeout - end - def existing_session @existing_session = journey_sessions.first end diff --git a/app/controllers/claims_form_callbacks.rb b/app/controllers/claims_form_callbacks.rb index 6ea3f6960d..9cf8c2dce0 100644 --- a/app/controllers/claims_form_callbacks.rb +++ b/app/controllers/claims_form_callbacks.rb @@ -103,11 +103,12 @@ def inject_hmrc_validation_attempt_count_into_the_form end def increment_hmrc_validation_attempt_count - session[:hmrc_validation_attempt_count] = current_hmrc_validation_attempt_count + 1 + journey_session.answers.hmrc_validation_attempt_count = current_hmrc_validation_attempt_count + 1 + journey_session.save! end def current_hmrc_validation_attempt_count - session[:hmrc_validation_attempt_count] || 0 + journey_session.answers.hmrc_validation_attempt_count || 0 end def on_tid_route? diff --git a/app/controllers/concerns/claim_session_timeout.rb b/app/controllers/concerns/claim_session_timeout.rb deleted file mode 100644 index d368229d05..0000000000 --- a/app/controllers/concerns/claim_session_timeout.rb +++ /dev/null @@ -1,25 +0,0 @@ -module ClaimSessionTimeout - CLAIM_TIMEOUT_LENGTH_IN_MINUTES = 30 - - def clear_claim_session - session.delete(:claim_postcode) - session.delete(:claim_address_line_1) - session.delete(:no_address_selected) - session.delete(:reminder_id) - session.delete(:slugs) - session.delete(:bank_validation_attempt_count) - session.delete(:user_info) - session.delete(:tps_school_id) - session.delete(:tps_school_name) - session.delete(:tps_school_address) - clear_journey_sessions! - end - - def claim_session_timed_out? - claim_in_progress? && session[:last_seen_at] < claim_timeout_in_minutes.minutes.ago - end - - def claim_timeout_in_minutes - self.class::CLAIM_TIMEOUT_LENGTH_IN_MINUTES - end -end diff --git a/app/controllers/concerns/journey_concern.rb b/app/controllers/concerns/journey_concern.rb index 2fda3e1d9d..a78afe6d87 100644 --- a/app/controllers/concerns/journey_concern.rb +++ b/app/controllers/concerns/journey_concern.rb @@ -22,7 +22,7 @@ def journey_session end def answers - journey_session.answers + journey_session&.answers end def claim_in_progress? diff --git a/app/controllers/concerns/session_management.rb b/app/controllers/concerns/session_management.rb new file mode 100644 index 0000000000..d04a90fe5c --- /dev/null +++ b/app/controllers/concerns/session_management.rb @@ -0,0 +1,6 @@ +module SessionManagement + def clear_claim_session + session.delete(:slugs) + clear_journey_sessions! + end +end diff --git a/app/controllers/journeys/additional_payments_for_teaching/reminders_controller.rb b/app/controllers/journeys/additional_payments_for_teaching/reminders_controller.rb index 9aeb93d102..bd60a7a670 100644 --- a/app/controllers/journeys/additional_payments_for_teaching/reminders_controller.rb +++ b/app/controllers/journeys/additional_payments_for_teaching/reminders_controller.rb @@ -45,9 +45,9 @@ def current_reminder end def reminder_from_session - return unless session.key?(:reminder_id) + return unless answers&.reminder_id - Reminder.find(session[:reminder_id]) + Reminder.find(answers.reminder_id) end def submitted_claim @@ -70,7 +70,7 @@ def build_reminder_from_claim # We can tell if we're setting a reminder for a submitted claim as the # journey session will be nil given that we clear it on claim submission. def model_for_reminder_attributes - @model_for_reminder_attributes ||= journey_session&.answers || submitted_claim + @model_for_reminder_attributes ||= answers || submitted_claim end def send_to_start? @@ -90,7 +90,6 @@ def clear_sessions return unless current_slug == "set" session.delete(journey_session_key) - session.delete(:reminder_id) end end end diff --git a/app/controllers/journeys/additional_payments_for_teaching/reminders_form_callbacks.rb b/app/controllers/journeys/additional_payments_for_teaching/reminders_form_callbacks.rb index 415a32f1dd..d2b6549973 100644 --- a/app/controllers/journeys/additional_payments_for_teaching/reminders_form_callbacks.rb +++ b/app/controllers/journeys/additional_payments_for_teaching/reminders_form_callbacks.rb @@ -14,7 +14,8 @@ def email_verification_before_update end def personal_details_after_form_save_success - update_reminder_id + answers.reminder_id = current_reminder.to_param + journey_session.save! try_mailer { send_verification_email } || return redirect_to_next_slug end @@ -40,10 +41,6 @@ def inject_sent_one_time_password_at_into_the_form params[:form]&.[]=(:sent_one_time_password_at, session[:sent_one_time_password_at]) end - def update_reminder_id - session[:reminder_id] = current_reminder.to_param - end - def send_verification_email otp = OneTimePassword::Generator.new ReminderMailer.email_verification(current_reminder, otp.code).deliver_now diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb deleted file mode 100644 index be7df512a7..0000000000 --- a/app/controllers/sessions_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class SessionsController < BasePublicController - skip_before_action :end_expired_claim_sessions - - def refresh - clear_claim_session if claim_session_timed_out? - - head :ok - end -end diff --git a/app/models/journeys/session_answers.rb b/app/models/journeys/session_answers.rb index e85bd27b98..433f8d1186 100644 --- a/app/models/journeys/session_answers.rb +++ b/app/models/journeys/session_answers.rb @@ -44,6 +44,8 @@ class SessionAnswers attribute :student_loan_plan, :string attribute :submitted_using_slc_data, :boolean attribute :sent_one_time_password_at, :datetime + attribute :hmrc_validation_attempt_count, :integer + attribute :reminder_id, :string def has_attribute?(name) attribute_names.include?(name.to_s) diff --git a/app/views/claims/no_address_found.html.erb b/app/views/claims/no_address_found.html.erb deleted file mode 100644 index 1f7eb6cfe0..0000000000 --- a/app/views/claims/no_address_found.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -<% content_for(:page_title, page_title(t("questions.address.home.no_address_found"), journey: current_journey_routing_name, show_error: journey_session.errors.any?)) %> - -
-
- <%= render("shared/error_summary", instance: journey_session) if journey_session.errors.any? %> - - <%= form_for journey_session, url: claim_path(current_journey_routing_name), method: :get do |form| %> -
- -

<%= t("questions.address.home.no_address_found") %>

-
- -

- We have not been able to find your address. Check the details you have - provided, or enter your address manually. -

- -

Postcode

-

- <%= session[:claim_postcode] %> - <%= link_to "Change", claim_path(current_journey_routing_name, "postcode-search"), class: "govuk-link govuk-!-margin-left-3", "aria-label": "Change" %> -

- - <% if session[:claim_address_line_1].present? %> -

House number or name

-

- <%= session[:claim_address_line_1] %> - <%= link_to "Change", claim_path(current_journey_routing_name, "postcode-search"), class: "govuk-link govuk-!-margin-left-3", "aria-label": "Change" %> -

- <% end %> - - <%= link_to "Enter your address manually", claim_path(current_journey_routing_name, "address"), class: "govuk-button", role: "button", data: {module: "govuk-button"} %> - <% end %> -
-
diff --git a/app/views/claims/timeout.html.erb b/app/views/claims/timeout.html.erb deleted file mode 100644 index caf923af8b..0000000000 --- a/app/views/claims/timeout.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<% content_for(:page_title, page_title("Your session has ended due to inactivity", journey: current_journey_routing_name,)) %> - -
-
-

- Your session has ended due to inactivity -

- -

- Your session ended because you haven't done anything for <%= claim_timeout_in_minutes %> minutes -

- - <%= link_to "Start your application again", start_page_url(current_journey_routing_name), class: "govuk-button", role: "button", data: {module: "govuk-button"} %> -
-
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7ec0313734..05ceadae8a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -42,8 +42,6 @@ <% end %> - <%= render("timeout_dialog", timeout_in_minutes: claim_timeout_in_minutes, path_on_timeout: timeout_claim_path(current_journey_routing_name), refresh_session_path: refresh_session_path) if claim_in_progress? %> - Skip to main content