From 17fa5413f6c3ffd7fe1c450dc837ff7ee3ad8c9e Mon Sep 17 00:00:00 2001 From: Josh Pigford Date: Thu, 1 May 2025 17:14:59 -0500 Subject: [PATCH] Enhance onboarding logic to account for recent trial starts - Added a check to determine if a trial was started within the last few seconds, allowing for the assumption that onboarding was just completed even if the onboarded_at timestamp appears blank momentarily. This improves the user experience during onboarding transitions. --- app/controllers/concerns/onboardable.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/concerns/onboardable.rb b/app/controllers/concerns/onboardable.rb index 804667b4..66f89ba9 100644 --- a/app/controllers/concerns/onboardable.rb +++ b/app/controllers/concerns/onboardable.rb @@ -18,7 +18,11 @@ module Onboardable return unless Current.user return unless redirectable_path?(request.path) - if Current.user.onboarded_at.blank? + # Check if trial was started VERY recently (e.g., within the last few seconds) + # If so, assume onboarding was just completed in the previous request, even if onboarded_at appears blank momentarily. + trial_just_started = Current.family.trial_started_at.present? && Current.family.trial_started_at > 10.seconds.ago + + if Current.user.onboarded_at.blank? && !trial_just_started redirect_to onboarding_path elsif !Current.family.subscribed? && !Current.family.trialing? redirect_to upgrade_subscription_path