I am using Devise in a rail app.
I have two models : User and Admin.
Currently, I am able to login as both User and Admin if i visit the User sign in and the admin sign in.
I would like to force a logout of one if the other signs in. What’s the best way to do that?
Also, if anyone has a good way to test that in rspec/capybara, please do share!
Thanks
I would copy over the Devise Controllers and add a before filter like so:
Then for the testing you can access the current user in functional(controller) specs by calling subject.current_user or subject.current_admin, go here: https://github.com/plataformatec/devise to make sure to include the test helpers then try something like this: