You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
752 B

  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 ID',
  9. useForm: false,
  10. props: ['clientId', 'clientSecret'],
  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. }