google.js 765 B

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