Sessions in Sinatra using Facebook authentication

2019-04-14 10:19发布

问题:

I'm very new to ruby & Sinatra and I have a basic question:

The app I'm trying to build will use Facebook as it's sole method of authenticating users into the app. I want to store a local users table which will contain only the facebook uid along with some user preferences. I have looked at a couple of gems which allow me to authenticate against the facebook API, however I am unsure how to control sessions within my application once I have established the user is valid. I have been using the koala gem for talking to facebook, and I have also seen the sinatra-session gem for running the session side of things.

Can someone point me in the right direction as to how I can manage my sessions once a user has logged in using their facebook account?

回答1:

I wrote an example sinatra app with this functionality and used the built-in sessions from sinatra. look here, maybe this helps you: https://github.com/benben/simple-ruby-facebook-example