-
Notifications
You must be signed in to change notification settings - Fork 1
/
passports.js
48 lines (43 loc) · 1.37 KB
/
passports.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
40
41
42
43
44
45
46
47
48
/**
* Created by Jaewook on 2015-08-01.
*/
var passport = require('passport');
var FacebookStrategy = require('passport-facebook').Strategy;
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var pkginfo = require('./package');
//Serialize
//인증후 사용자 정보를 세션에 저장
passport.serializeUser(function (user, done) {
done(null, user);
});
//deserialize
//인증후, 사용자 정보를 세션에서 읽어서 reqeust.user에 저장
passport.deserializeUser(function (user, done) {
done(null, user);
});
passport.use(new FacebookStrategy({
clientID: pkginfo.oauth.facebook.FACEBOOK_APP_ID,
clientSecret: pkginfo.oauth.facebook.FACEBOOK_APP_SECRET,
callbackURL: pkginfo.oauth.facebook.callbackURL,
profileFields: ['email']
},
function (accessToken, refreshToken, profile, done) {
var user = {
email : profile._json.email
};
return done(null, user);
}
));
passport.use(new GoogleStrategy({
clientID: pkginfo.oauth.google.GOOGLE_APP_ID,
clientSecret: pkginfo.oauth.google.GOOGLE_APP_SECRET,
callbackURL: pkginfo.oauth.google.callbackURL
},
function (accessToken, refreshToken, profile, done) {
var user = {
email : profile._json.emails[0].value
};
return done(null, user);
}
));
module.exports = passport;