google.js 774 B

1234567891011121314151617181920212223242526272829303132
  1. /* global WIKI */
  2. // ------------------------------------
  3. // Google ID Account
  4. // ------------------------------------
  5. const GoogleStrategy = require('passport-google-oauth20').Strategy
  6. module.exports = {
  7. key: 'google',
  8. title: 'Google',
  9. useForm: false,
  10. props: {
  11. clientId: String,
  12. clientSecret: String
  13. },
  14. init (passport, conf) {
  15. passport.use('google',
  16. new GoogleStrategy({
  17. clientID: conf.clientId,
  18. clientSecret: conf.clientSecret,
  19. callbackURL: conf.callbackURL
  20. }, (accessToken, refreshToken, profile, cb) => {
  21. WIKI.db.users.processProfile(profile).then((user) => {
  22. return cb(null, user) || true
  23. }).catch((err) => {
  24. return cb(err, null) || true
  25. })
  26. })
  27. )
  28. }
  29. }