Skip to content

Commit afeef31

Browse files
committed
#5100: Fix unknown format error on expired session
1 parent c5601ef commit afeef31

6 files changed

Lines changed: 20 additions & 1 deletion

File tree

app/controllers/application_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class ApplicationController < ActionController::Base
1515

1616
rescue_from ActiveRecord::RecordNotFound, with: :not_found!
1717

18-
rescue_from ActionController::InvalidAuthenticityToken do
18+
rescue_from ActionController::InvalidAuthenticityToken, with: :session_expired
19+
20+
def session_expired
1921
flash[:error] = "Your session expired. This could be due to leaving a page open for a long time, or having multiple tabs open. Try resubmitting."
2022
redirect_back fallback_location: root_path
2123
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Validatable
2+
extend ActiveSupport::Concern
3+
4+
included do
5+
rescue_from ActionController::InvalidAuthenticityToken do
6+
if action_name == 'validate'
7+
render json: { valid: false }
8+
else
9+
session_expired
10+
end
11+
end
12+
end
13+
end

app/controllers/distributions_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class DistributionsController < ApplicationController
77
include DateRangeHelper
88
include DistributionHelper
9+
include Validatable
910

1011
before_action :enable_turbo!, only: %i[new show]
1112
skip_before_action :authenticate_user!, only: %i(calendar)

app/controllers/partners/family_requests_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Partners
22
class FamilyRequestsController < BaseController
3+
include Validatable
34
before_action :verify_partner_is_active
45
before_action :authorize_verified_partners
56

app/controllers/partners/individuals_requests_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Partners
22
class IndividualsRequestsController < BaseController
3+
include Validatable
34
before_action :verify_partner_is_active
45
before_action :authorize_verified_partners
56

app/controllers/partners/requests_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Partners
22
class RequestsController < BaseController
3+
include Validatable
34
skip_before_action :require_partner, only: [:new, :create, :validate]
45
before_action :require_partner_or_org_admin, only: [:new, :create, :validate]
56
layout :layout

0 commit comments

Comments
 (0)