-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupPassport.js
33 lines (29 loc) · 967 Bytes
/
setupPassport.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
const GoogleStrategy = require("passport-google-oauth").OAuth2Strategy;
const passport = require("passport");
const UserService = require("./services/UserService");
const setupPassport = () => {
passport.serializeUser((user, done) => {
console.log("serialize user", user);
done(null, user.id);
});
passport.deserializeUser(async (id, done) => {
const user = await UserService.getUser(id);
done(null, user);
});
passport.use(
new GoogleStrategy(
{
clientID:
"17046437582-pbhk4jniie6m0p7llcttm3r4770t6tv2.apps.googleusercontent.com",
clientSecret: "fnTOqOhBNLB7wvsU5MkfpHj1",
callbackURL:
"https://limitless-inlet-11254.herokuapp.com/auth/google/callback",
},
async (accessToken, refreshToken, profile, done) => {
const user = await UserService.findByGoogleIdOrCreate(profile);
return done(null, user);
}
)
);
};
module.exports = setupPassport;