Rails - Throw Invalid Authentication Authentication Exception

I am currently using the RESTful Authentication plugin for my rails application.

There is a typical scenario where the user remains on the login screen for a long time (say, 1 day ..), which makes the authentication token invalid due to expiration.

When this user tries to log into the system the next day (he has not updated, he is still with this invalid token), he will receive a "500" http error. Create an application crash for this request.

I am wondering if it is possible to catch and warn the user. Like any other innocent web user, he just comes back and tries again ... and gets the same error again ...

+6
ruby-on-rails exception authenticity-token
source share
2 answers

In your application application_controller.rb you will do something like:

rescue_from Your::Exception, :with => :show_some_error_page 

This will allow you to show some action, in this case show_some_error_page , when an unhandled exception occurs.

Hope this helps.

+11
source share

If this often happens for a specific controller action, you can also disable authentication token verification for this action ...

 skip_before_filter :verify_authenticity_token, :only => [:create] 
-2
source share

All Articles