From cb1e215d0bf488861c87e22691056a0ea6b862fb Mon Sep 17 00:00:00 2001 From: Alkesh Vaghmaria Date: Mon, 5 Aug 2024 17:28:46 +0100 Subject: [PATCH] use callback --- app/controllers/claims_form_callbacks.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/controllers/claims_form_callbacks.rb b/app/controllers/claims_form_callbacks.rb index 9cf8c2dce0..bde97e9634 100644 --- a/app/controllers/claims_form_callbacks.rb +++ b/app/controllers/claims_form_callbacks.rb @@ -64,6 +64,17 @@ def postcode_search_after_form_save_failure end end + def consent_before_show + if page_sequence.magic_link? + otp = OneTimePassword::Validator.new(params[:code], answers.sent_one_time_password_at) + if otp.valid? # && EligibleEyProvider.eligible_email?(answers.email_address) # TODO eligible check once model merged: https://github.com/DFE-Digital/claim-additional-payments-for-teaching/pull/3050 + answers.assign_attributes(email_verified: true) + journey_session.save! + session[:slugs] << page_sequence.next_required_slug + end + end + end + private def set_backlink_override_to_current_slug