Skip to content

Commit

Permalink
CAPT-1773 remove 30min timeout (#3035)
Browse files Browse the repository at this point in the history
remove 30min timeout.

ClaimSessionTimeout concern is no more.

Here is a breakdown of the session entries it used to delete:
  claim_postcode and claim_address_line_1 were used in the view app/views/claims/no_address_found.html.erb which was never actually used
  no_address_selected - not used
  reminder_id - has been moved into journey session answers
  slugs - remains in the session, cleared by ClaimsController when the user changes to a different journey, or for new claims. Also cleared by SubmissionsController when the claim is submitted.
  bank_validation_attempt_count - not used
  user_info - not used
  tps_school_id, tps_school_name and tps_school_address - not used

Also session[:hmrc_validation_attempt_count] has been moved into journey session answers.
  • Loading branch information
alkesh authored Jul 30, 2024
1 parent c307f6d commit 4dc7151
Show file tree
Hide file tree
Showing 21 changed files with 20 additions and 236 deletions.
11 changes: 1 addition & 10 deletions app/controllers/base_public_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions app/controllers/claims_controller.rb
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -14,9 +14,6 @@ class ClaimsController < BasePublicController
include FormSubmittable
include ClaimsFormCallbacks

def timeout
end

def existing_session
@existing_session = journey_sessions.first
end
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/claims_form_callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
25 changes: 0 additions & 25 deletions app/controllers/concerns/claim_session_timeout.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/concerns/journey_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def journey_session
end

def answers
journey_session.answers
journey_session&.answers
end

def claim_in_progress?
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/concerns/session_management.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module SessionManagement
def clear_claim_session
session.delete(:slugs)
clear_journey_sessions!
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand All @@ -90,7 +90,6 @@ def clear_sessions
return unless current_slug == "set"

session.delete(journey_session_key)
session.delete(:reminder_id)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 0 additions & 9 deletions app/controllers/sessions_controller.rb

This file was deleted.

2 changes: 2 additions & 0 deletions app/models/journeys/session_answers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
35 changes: 0 additions & 35 deletions app/views/claims/no_address_found.html.erb

This file was deleted.

15 changes: 0 additions & 15 deletions app/views/claims/timeout.html.erb

This file was deleted.

2 changes: 0 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
</noscript>
<% 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? %>

<a href="#main-content" class="govuk-skip-link">Skip to main content</a>

<div id="global-cookie-message" class="govuk-cookie-banner" role="region" aria-label="cookie banner">
Expand Down
2 changes: 1 addition & 1 deletion app/views/static_pages/cookies.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<tr class="govuk-table__row">
<td class="govuk-table__cell">_dfe_teachers_payment_service_session</td>
<td class="govuk-table__cell">Stores session data</td>
<td class="govuk-table__cell">After <%= claim_timeout_in_minutes %> minutes</td>
<td class="govuk-table__cell">After 24 hours</td>
</tr>
</tbody>
</table>
Expand Down
3 changes: 0 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
# setup a simple healthcheck endpoint for monitoring purposes
get "/healthcheck", to: proc { [200, {}, ["OK"]] }

get "refresh-session", to: "sessions#refresh", as: :refresh_session

# Used to constrain claim journey routing so only slugs
# that are part of a journey's slug sequence are routed.
restrict_to_sequence_slugs = Class.new {
Expand Down Expand Up @@ -47,7 +45,6 @@ def matches?(request)
post "claim", as: :claims, to: "claims#create"
post "claim/submit", as: :claim_submission, to: "submissions#create"
get "claims/confirmation", as: :claim_confirmation, to: "submissions#show"
get "timeout", to: "claims#timeout", as: :timeout_claim
get "existing-session", as: :existing_session, to: "claims#existing_session"
post "start-new", to: "claims#start_new", as: :start_new

Expand Down
1 change: 0 additions & 1 deletion spec/features/changing_answers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
expect(find("#claim_qts_award_year_on_or_after_cut_off_date").checked?).to eq(true)

choose_qts_year :before_cut_off_date
click_on "Continue"

expect(session.reload.answers.qts_award_year).to eq("before_cut_off_date")

Expand Down
31 changes: 0 additions & 31 deletions spec/features/timeout_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/requests/claims_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,6 @@ def check_slug_redirection
end
end

describe "claims#timeout" do
before { create(:journey_configuration, :student_loans) }

it "displays session timeout content" do
get timeout_claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME)
expect(response.body).to include("Your session has ended due to inactivity")
end
end

describe "claims#update request" do
before { create(:journey_configuration, :student_loans) }

Expand Down
30 changes: 0 additions & 30 deletions spec/requests/sessions_spec.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/requests/submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
expect(email[:personalisation].decoded).to include("ref_number")
expect(email[:personalisation].decoded).to include(submitted_claim.reference)

expect(session[:claim_id]).to be_nil
expect(session[:slugs]).to be_nil
expect(session[:submitted_claim_id]).to eq(submitted_claim.id)
end
Expand Down
Loading

0 comments on commit 4dc7151

Please sign in to comment.