YouAndWeb_TwoToc
a98e8d4c8be3c9266abcdd007f47a6b1c3ed9599
YouAndWeb_TwoToc / .fr-KzWVa7 / twotoc / server / auth / google / passport.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
var passport = require('passport'); var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy; exports.setup = function(User, config) { passport.use(new GoogleStrategy({ clientID: config.google.clientID, clientSecret: config.google.clientSecret, callbackURL: config.google.callbackURL }, function(accessToken, refreshToken, profile, done) { User.findOneAsync({ 'google.id': profile.id }) .then(function(user) { if (!user) { user = new User({ name: profile.displayName, email: profile.emails[0].value, role: 'user', username: profile.emails[0].value.split('@')[0], provider: 'google', google: profile._json }); user.saveAsync() .then(function(user) { return done(null, user); }) .catch(function(err) { return done(err); }); } else { return done(null, user); } }) .catch(function(err) { return done(err); }); })); }; |
Commits for YouAndWeb_TwoToc.fr-KzWVa7/twotoc/server/auth/google/passport.js
Revision | Author | Commited | Message |
---|---|---|---|
a98e8d ... | FSinnona | Thu 26 Nov, 2015 13:26:45 +0000 | Creazione organizza |