<commit_before>//
// Runs Passport.js setup code including mounting strategies, serializers, etc.
//

const passport = require("passport")
const FacebookStrategy = require("passport-facebook").Strategy
const AppleStrategy = require("passport-apple")
const GoogleStrategy = require("passport-google-oauth20").Strategy
const LocalWithOtpStrategy = require("lib/passport-local-with-otp/lib").Strategy
const callbacks = require("./callbacks")
const { serialize, deserialize } = require("./serializers")
const opts = require("../options")

module.exports = function () {
  passport.serializeUser(serialize)
  passport.deserializeUser(deserialize)
  passport.use(
    new LocalWithOtpStrategy(
      {
        usernameField: "email",
        otpField: "otp_attempt",
        passReqToCallback: true,
      },
      callbacks.local
    )
  )

  if (opts.FACEBOOK_ID && opts.FACEBOOK_SECRET) {
    passport.use(
      new FacebookStrategy(
        {
          state: true,
          clientID: opts.FACEBOOK_ID,
          clientSecret: opts.FACEBOOK_SECRET,
          passReqToCallback: true,
          callbackURL: `${opts.APP_URL}${opts.facebookCallbackPath}`,
        },
        callbacks.facebook
      )
    )
  }

  if (opts.GOOGLE_CLIENT_ID && opts.GOOGLE_SECRET) {
    passport.use(
      new GoogleStrategy(
        {
          state: true,
          clientID: opts.GOOGLE_CLIENT_ID,
          clientSecret: opts.GOOGLE_SECRET,
          passReqToCallback: true,
          callbackURL: `${opts.APP_URL}${opts.googleCallbackPath}`,
        },
        callbacks.google
      )
    )
  }

  if (
    opts.APPLE_CLIENT_ID &&
    opts.APPLE_TEAM_ID &&
    opts.APPLE_KEY_ID &&
    opts.APPLE_PRIVATE_KEY
  ) {
    passport.use(
      new AppleStrategy(<commit_msg>fix: Add scope parameter to Google strategy<commit_after>//
// Runs Passport.js setup code including mounting strategies, serializers, etc.
//

const passport = require("passport")
const FacebookStrategy = require("passport-facebook").Strategy
const AppleStrategy = require("passport-apple")
const GoogleStrategy = require("passport-google-oauth20").Strategy
const LocalWithOtpStrategy = require("lib/passport-local-with-otp/lib").Strategy
const callbacks = require("./callbacks")
const { serialize, deserialize } = require("./serializers")
const opts = require("../options")

module.exports = function () {
  passport.serializeUser(serialize)
  passport.deserializeUser(deserialize)
  passport.use(
    new LocalWithOtpStrategy(
      {
        usernameField: "email",
        otpField: "otp_attempt",
        passReqToCallback: true,
      },
      callbacks.local
    )
  )

  if (opts.FACEBOOK_ID && opts.FACEBOOK_SECRET) {
    passport.use(
      new FacebookStrategy(
        {
          state: true,
          clientID: opts.FACEBOOK_ID,
          clientSecret: opts.FACEBOOK_SECRET,
          passReqToCallback: true,
          callbackURL: `${opts.APP_URL}${opts.facebookCallbackPath}`,
        },
        callbacks.facebook
      )
    )
  }

  if (opts.GOOGLE_CLIENT_ID && opts.GOOGLE_SECRET) {
    passport.use(
      new GoogleStrategy(
        {
          state: true,
          clientID: opts.GOOGLE_CLIENT_ID,
          clientSecret: opts.GOOGLE_SECRET,
          passReqToCallback: true,
          callbackURL: `${opts.APP_URL}${opts.googleCallbackPath}`,
          scope: ["profile", "email"],
        },
        callbacks.google
      )
    )
  }

  if (
    opts.APPLE_CLIENT_ID &&
    opts.APPLE_TEAM_ID &&
    opts.APPLE_KEY_ID &&
    opts.APPLE_PRIVATE_KEY
  ) {
    passport.use(
      new AppleStrategy(
{'fraction_non_alphanumeric': 0.11374407582938388, 'fraction_numerical': 0.001115137998327293, 'mean_word_length': 2.72972972972973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3938671', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1112, 'n_words': 190}