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.

35 lines
890 B

  1. /* global WIKI */
  2. // ------------------------------------
  3. // GitLab Account
  4. // ------------------------------------
  5. const GitLabStrategy = require('passport-gitlab2').Strategy
  6. const _ = require('lodash')
  7. module.exports = {
  8. init (passport, conf) {
  9. passport.use('gitlab',
  10. new GitLabStrategy({
  11. clientID: conf.clientId,
  12. clientSecret: conf.clientSecret,
  13. callbackURL: conf.callbackURL,
  14. baseURL: conf.baseUrl,
  15. scope: ['read_user']
  16. }, async (accessToken, refreshToken, profile, cb) => {
  17. try {
  18. const user = await WIKI.models.users.processProfile({
  19. profile: {
  20. ...profile,
  21. picture: _.get(profile, 'avatarUrl', '')
  22. },
  23. providerKey: 'gitlab'
  24. })
  25. cb(null, user)
  26. } catch (err) {
  27. cb(err, null)
  28. }
  29. }
  30. ))
  31. }
  32. }