Last active
April 13, 2016 00:37
-
-
Save BerkeleyTrue/bfaf1e8dac5e9857ed6fe254809f7c6a to your computer and use it in GitHub Desktop.
Loopback's default deserialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
passport.deserializeUser(function(id, done) { | |
// DB query 1: | |
// Find the user in the database | |
// This is where the largest amount of data is sent | |
// back form the database | |
self.userModel.findById(id, function(err, user) { | |
if (err || !user) { | |
return done(err, user); | |
} | |
// DB query 2: | |
// grab the identity object | |
// this contains their oauth data | |
// we actually don't use this information | |
// anywhere in our codebase | |
user.identities(function(err, identities) { | |
user.profiles = identities; | |
// DB query 3: grab their credentials | |
// This is a mistery to me why this exist. | |
// I'm glad we can get ride of this request | |
user.credentials(function(err, accounts) { | |
user.accounts = accounts; | |
done(err, user); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment