Skip to content

nparziale/passport-parse-verify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passport-parse-verify

Installation

$ npm install passport-parse-verify --save

Usage

Just generate a callback for Passport Strategies using VerifyWithParse:

passport.use(
	new LinkedInStrategy({
		consumerKey: LINKEDIN_API_KEY
		, consumerSecret: LINKEDIN_SECRET_KEY
		, callbackURL: "http://127.0.0.1:3000/auth/linkedin/callback"
		, passReqToCallback: true
		}
	, VerifyWithParse.verify()
));

Note: setting passReqToCallback to true is required to have multiple linked accounts

Serialize saves Parse.User's sessionToken, and Deserialize finds a Parse.User based on it.

passport.serializeUser(VerifyWithParse.serializeUser);
passport.deserializeUser(VerifyWithParse.deserializeUser);

Finding all user's accounts is as simple as:

app.get('/account', ensureAuthenticated
, function(req, res, next){
	req.user.relation("accounts").query().find()
	.then(function(results){
		req.accounts = results;
		next();
	});
}
, function(req, res){
	var accounts = {};
	_.each(req.accounts, function(account){
		accounts[account.get("provider")] = account.toJSON();
	});
	res.render('account', {
		accounts: accounts
	});
});

Note: Code available in examples/ folder.

Credits

License

The MIT License

Copyright (c) 2014 Nicolás Parziale

About

Verify callback for PassportJS using Parse.com support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published