I am using the devise, omniauth, omniauth-twitter and twitter gems in a rails 3 app. I want to make it so when a user signs out it also removes the twitter gem configuration. What I’m referring to when I say “twitter gem configuration” is this:
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
If I don’t do that and another user logs onto the app from the same computer but doesn’t have a user account, they will see the previous user’s twitter information. I believe I can remove the configuration by calling
Twitter.reset
I guess my question is where would be the best place to put that? Also if that isn’t the best way to remove the user’s twitter configuration, how should I do it?
Thanks and let me know if you need any more details.
This seems to be working.
In
/app/controllers/application_controller.rbyou can redirect the default route devise sends the user when they sign_in/out. I’m not sure if this is the “proper” place to put this but it seems reasonable.The
authentications_pathis just the page I’m using to test the authentications and related things. You can redirect anywhere. When a user links an account I save their oauth token and secret in the authentication object. You will need this to access certain aspects of the Twitter gem.I’ll wait a little while to mark this as the answer, see if someone has a better solution.