Skip to content

Commit fce0ae6

Browse files
Added handler to, on an invalid CSRF token, redirect back and flash a friendly message
1 parent f913433 commit fce0ae6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/controllers/application_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class ApplicationController < ActionController::Base
1414

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

17+
rescue_from ActionController::InvalidAuthenticityToken do
18+
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.'
19+
redirect_back fallback_location: root_path
20+
end
21+
1722
def current_organization
1823
return @current_organization if @current_organization
1924
return nil unless current_role

0 commit comments

Comments
 (0)