Created
December 27, 2019 17:09
-
-
Save kp666/b838329891f1652040934399a8297fc7 to your computer and use it in GitHub Desktop.
sample.js
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
app.post('/login', function (req, res, next) { | |
passport.use(new GoogleStrategy({ | |
clientID: process.env.CLIENT_ID, | |
clientSecret: process.env.CLIENT_SECRET, | |
callbackURL: "http://localhost:3000/auth/google/dashboard", | |
userProfileURL: "https://www.googleapis.com/oauth2/v3/userinfo" | |
}, | |
function(accessToken, refreshToken, profile, cb) { | |
if(profile._json.hd === "nitc.ac.in"){ | |
User.findOrCreate({ googleId: profile.id ,displayName:profile.displayName,email:profile.emails[0].value}, function (err, user) { | |
return cb(err, user); | |
}); | |
}else{ | |
res.redirect('/login_failed'); | |
} | |
} | |
)) | |
});; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment