Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding some more documentation on serializeUser and deserializeUser

  • Loading branch information...
commit 165fb0d0d71689433eb1509e6ee05b5eff94d662 1 parent 65d83d1
@travist authored
Showing with 28 additions and 4 deletions.
  1. +28 −4 README.md
View
32 README.md
@@ -56,11 +56,35 @@ var fipassport = require('flatiron-passport');
var app = flatiron.app;
// Use the passport strategy.
-passport.use(new LocalStrategy(
- function(username, password, done) {
+passport.use(new LocalStrategy(function(username, password, done) {
+
+ // Use this as you normally would in Passport.js.
+ // But for now just
+ // hard-code the user object.
+ done(null, {
+ id: 1234,
+ username: username,
+ password: password
+ });
+}});
+
+// Serialize based on the user ID.
+passport.serializeUser(function(user, done) {
+
+ // @todo: Save your user to the database using the ID as a key.
+ done(null, user.id);
+});
+
+// Load the user and return it to passport.
+passport.deserializeUser(function(id, done) {
- // Use this as you normally would in Passport.js
- }
+ // @todo: Load your user here based off of the ID, and call done with
+ // that user object.
+ done(null, {
+ id:id,
+ username:'foo',
+ password:'bar'
+ });
});
app.use(flatiron.plugins.http);
Please sign in to comment.
Something went wrong with that request. Please try again.