google.js 774 Bytes
Newer Older
1
/* global WIKI */
2 3 4 5 6 7 8

// ------------------------------------
// Google ID Account
// ------------------------------------

const GoogleStrategy = require('passport-google-oauth20').Strategy

9 10
module.exports = {
  key: 'google',
11
  title: 'Google',
12
  useForm: false,
13 14 15 16
  props: {
    clientId: String,
    clientSecret: String
  },
17 18 19 20 21 22 23
  init (passport, conf) {
    passport.use('google',
      new GoogleStrategy({
        clientID: conf.clientId,
        clientSecret: conf.clientSecret,
        callbackURL: conf.callbackURL
      }, (accessToken, refreshToken, profile, cb) => {
24
        WIKI.db.users.processProfile(profile).then((user) => {
25 26 27 28
          return cb(null, user) || true
        }).catch((err) => {
          return cb(err, null) || true
        })
29 30
      })
    )
31
  }
32
}