I am developing a Rails3 application using Devise for authentication. In the course of the workflow, data like patient_id is stored in the session. However, when the user log's out, the session needs to be cleared. I am unable to figure out how to reset session data since Devise handles users login / logout and I not having control over it.
How to handle this situation?
Overwrite Devise::SessionsController like this:
class SessionsController < Devise::SessionsController
respond_to :html
def destroy
super
reset_session
end
end
Don't forget to move the devise views to the right place (views/devise/sessions to views/sessions) and modify the devise route to point to your controller. For example:
devise_for :users, :controllers => { :sessions => "sessions" }
See the devise docs on github for more details or the link posted by Bill.
I believe you'd have to over ride the devise controllers, there's a good post here on that:
Devise, CanCan and customizing devise controllers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With