Passport is an easy way to access to multiple provider. The first utility is for login connection, but in other case you may be want just access to provider informations and make what you want. In this case i create a link between basic user account and providers accounts
$ git clone [email protected]:hack1337/sails-passport-providers.git
$ cd sails-passport-providers
$ npm install
$ sails lift
Realy easy to add your favorite provider, in config/passport.js
you can add your provider settings.
- Create app on your provider site
- Install the provider passport node module
- Create provider strategie
- Configure the strategie
- Add the button on the view
You will find an exemple in config/passport.js
For all providers informations to configure strategies : Passport providers
Route to use for provider login is auth/:provider
On some exemple about login with provider, we can use provider just for login. In this case you have full access control on providers informations.
How use it ?
// Auth Controller
// providerLogin Action
providerLogin: function(req, res) {
// Set provider callback action
// Value is [controller].[action] in this case i'm in auth controller and providerLogin action
var session = {
key: 'provider',
value: 'auth.providerLogin'
};
sails.controllers.tools.setItemSession(req, session);
// Set provider name
var provider = req.param('provider');
// Retrieve provider information
sails.controllers.provider.getProviderProfile(req, res, provider)
.then(function (provider_profile) {
// Make what you want with provider_profile informations
});
}
- Expand readme
- Correct my English :)