-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
41 lines (37 loc) · 1.23 KB
/
index.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
const GoogleStrategy = require('passport-google-oauth20');
module.exports = ({ config, host, app }) => {
return {
auth({ providers, passport }) {
// google oauth
providers.push({ id: 'google', name: 'Google' });
passport.use(
new GoogleStrategy(
{
clientID: config.client_id,
clientSecret: config.client_secret,
callbackURL: `${host}/auth/google/callback`
},
(accessToken, refreshToken, profile, done) => {
done(null, profile);
}
)
);
app.get(
'/auth/google',
passport.authenticate('google', {
scope: ['https://www.googleapis.com/auth/plus.login']
})
);
app.get(
'/auth/google/callback',
passport.authenticate('google', {
failureRedirect: '/login'
}),
(request, reply) => {
reply.redirect('/success');
}
);
}
};
};
module.exports = {};