opened
mmkal
username_0
I realise this may be a little out of scope for a passport-facebook demo, but I think it'd make sense to have an example of how you could do storage in a database. Of course it wouldn't be worth setting up a real, persistent database, but it'd be a nice way to give the idea of _what_ to store by using a POJO. I'm coming to this reasonably new to node development, so the less comments I see that say things like "you wouldn't do it this way in a production-ready app", the better. You could probably get rid of most of those comment paragraphs above serialize- and deserializeUser that way too. 

Possible solution:

```JavaScript
// In a real app, you would use a regular database. 
// Using an in-memory dictionary here as a demo. 
var database = {};
...
passport.use(new FacebookStrategy({
    clientID: FACEBOOK_APP_ID,
    clientSecret: FACEBOOK_APP_SECRET,
    callbackURL: "http://localhost:3000/auth/facebook/callback"
  },
  function(accessToken, refreshToken, profile, cb) {
    database[profile.id] = profile;
    cb(null, user);
  }
));
...
passport.serializeUser(function(user, cb) {
  cb(null, user.id);
});

passport.deserializeUser(function(id, cb) {
  cb(null, database[id]);
});
```

For those of us with quite a lot of flexibility, not much context, and who just want to find the "normal way" to implement Facebook login, this would make it much easier to reason about where to drop in our data storage solution. 

If you'd be receptive, I'd be happy to submit something like the above as a pull request?
Add in user storage example 
issue
created
jaredhanson
username_1
The example has been updated to include user storage using SQLite.
comment
closed
jaredhanson
username_1
issue