From bf1be32d377cd87a77501c883bbf0867027868a6 Mon Sep 17 00:00:00 2001 From: carolyncole <1599081+carolyncole@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:30:36 -0500 Subject: [PATCH] Clear the session to allow the ssytem user to be refreshed (#1156) --- app/controllers/application_controller.rb | 26 +++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f4129ed88..8f23337a8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -45,32 +45,30 @@ def mediaflux_session_errors raise unless e.is_a?(Mediaflux::SessionExpired) || e.cause.is_a?(Mediaflux::SessionExpired) if session[:active_web_user] redirect_to mediaflux_passthru_path(path: request.path) + elsif session_error_handler + retry else - @retry_count ||= 0 - @retry_count += 1 - - current_user.mediaflux_from_session(session) - if @retry_count < 3 # If the session is expired we should not have to retry more than once, but let's have a little wiggle room - retry - else - raise - end + raise end end def mediaflux_login_errors yield rescue Mediaflux::SessionError + if session_error_handler + retry + else + raise + end + end + + def session_error_handler @retry_count ||= 0 @retry_count += 1 current_user.clear_mediaflux_session(session) current_user.mediaflux_from_session(session) - if @retry_count < 3 # If the session is expired we should not have to retry more than once, but let's have a little wiggle room - retry - else - raise - end + @retry_count < 3 # If the session is expired we should not have to retry more than once, but let's have a little wiggle room end def emulate_user