Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "passport-github2 in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'passport-github2' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

// set up db connection
  var db = require('./models/db')

  console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV'))

  // Passport session setup
  passport.serializeUser(function (user, done) {
    done(null, user)
  })

  passport.deserializeUser(function (user, done) {
    done(null, user)
  })

  // use GitHubStrategy with Passport
  passport.use(new GitHubStrategy({
    clientID: (process.env.GH_CLIENT_ID || config.github.clientID),
    clientSecret: (process.env.GH_CLIENT_SECRET || config.github.clientSecret),
    callbackURL: config.github.callbackURL,
    passReqToCallback: true
  },
  function (req, accessToken, refreshToken, extProfile, done) {
    auth.passportStrategySetup(req, accessToken, refreshToken, extProfile, done)
  }
  ))


  // use LinkedInStrategy with Passport
  passport.use(new LinkedInStrategy({
    clientID: (process.env.LI_CLIENT_ID || config.linkedin.clientID),
    clientSecret: (process.env.LI_CLIENT_SECRET || config.linkedin.clientSecret),
    callbackURL: config.linkedin.callbackURL,
// set up db connection
  var db = require('./models/db')

  console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV'))

  // Passport session setup
  passport.serializeUser(function (user, done) {
    done(null, user)
  })

  passport.deserializeUser(function (user, done) {
    done(null, user)
  })

  // use GitHubStrategy with Passport
  passport.use(new GitHubStrategy({
      clientID: (process.env.GH_CLIENT_ID || config.github.clientID),
      clientSecret: (process.env.GH_CLIENT_SECRET || config.github.clientSecret),
      callbackURL: config.github.callbackURL,
      passReqToCallback: true
    },
    function (req, accessToken, refreshToken, extProfile, done) {
      passportStrategySetup(req, accessToken, refreshToken, extProfile, done)
    }
  ))


  // use LinkedInStrategy with Passport
  passport.use(new LinkedInStrategy({
    clientID: (process.env.LI_CLIENT_ID || config.linkedin.clientID),
    clientSecret: (process.env.LI_CLIENT_SECRET || config.linkedin.clientSecret),
    callbackURL: config.linkedin.callbackURL,
// set up db connection
    var db = require('./app/models/db');

    console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV'));

    // Passport session setup
    passport.serializeUser(function (user, done) {
        done(null, user);
    });

    passport.deserializeUser(function (user, done) {
        done(null, user);
    });

    // use GitHubStrategy with Passport
    passport.use(new GitHubStrategy({
            clientID: (process.env.GH_CLIENT_ID || config.github.clientID),
            clientSecret: (process.env.GH_CLIENT_SECRET || config.github.clientSecret),
            callbackURL: config.github.callbackURL,
            passReqToCallback: true
        },
        function (req, accessToken, refreshToken, extProfile, done) {
            passportStrategySetup(req, accessToken, refreshToken, extProfile, done);
        }
    ));


    // use LinkedInStrategy with Passport
    passport.use(new LinkedInStrategy({
            clientID: (process.env.LI_CLIENT_ID || config.linkedin.clientID),
            clientSecret: (process.env.LI_CLIENT_SECRET || config.linkedin.clientSecret),
            callbackURL: config.linkedin.callbackURL,
return done(err);
                  });
              }
            })
            .catch(err => {
              return done(err);
            });
        });
      }
    )
  );

  // Use the Github Strategy within Passport.

  passport.use(
    new GitHubStrategy(
      {
        clientID: '49b48c42021706f2c9cf',
        clientSecret: 'e54641680cd932ed79f9ff7cdac450f5caf78277',
        callbackURL: githubCallBackURL
      },
      (accessToken, refreshToken, profile, done) => {
        console.log(profile);
        process.nextTick(() => {
          db.User
            .findOne({
              where: {
                github_id: profile.id
              }
            })
            .then(dbUserResults => {
              console.log(dbUserResults);
//   and deserialized.
  passport.serializeUser((user, done) => {
    // TODO tratar no firebase?
    done(null, user)
  })

  passport.deserializeUser((obj, done) => {
    // TODO tratar no firebase?
    done(null, obj)
  })

  // Use the GitHubStrategy within Passport.
  //   Strategies in Passport require a `verify` function, which accept
  //   credentials (in this case, an accessToken, refreshToken, and GitHub
  //   profile), and invoke a callback with a user object.
  passport.use(new Strategy({
    clientID: GITHUB_CLIENT_ID,
    clientSecret: GITHUB_CLIENT_SECRET,
    callbackURL: CALLBACK_URL
  }, (accessToken, refreshToken, profile, done) => {
    const credential = firebase.auth.GithubAuthProvider.credential(accessToken)

    profile.accessToken = accessToken
    profile.credential = credential

    // asynchronous verification, for effect...
    process.nextTick(() => {
      // To keep the example simple, the user's GitHub profile is returned to
      // represent the logged-in user.  In a typical application, you would want
      // to associate the GitHub account with a user record in your database,
      // and return that user instead.
      return done(null, profile)
// required for persistent login sessions
    // passport needs ability to serialize and unserialize users out of session

    // used to serialize the user for the session
    passport.serializeUser(function(user, done) {
        done(null, user.id);
    });

    // used to deserialize the user
    passport.deserializeUser(function(id, done) {
        User.findById(id, function(err, user) {
            done(err, user);
        });
    });

    passport.use(new GithubStrategy({
        clientID: GITHUB_CLIENT_ID,
        clientSecret: GITHUB_CLIENT_SECRET,
        callbackURL: "http://127.0.0.1:3000/auth/github/callback"
      },
      function(token, refreshToken, profile, done) {
        User.findOne({ githubId: profile.id }, function (err, user) {
        if (err) {
            return done(err);
        }
        // if the user is found, then log them in
        if (user) {
            return done(null, user); // user found, return that user
        } else {
            // if there is no user found with that facebook id, create them
            var newUser            = new User();
module.exports = function(passport) {

  passport.serializeUser(function(user, done) {
    done(null, user.id);
  });

  passport.deserializeUser(function(id, done) {
    User.findById(id, function(err, user) {
      done(err, user);
    });
  });

  // Модуль Стратегии авторизации.
  passport.use('github', new GitHubStrategy({
      clientID: configAuth.githubAuth.clientID,
      clientSecret: configAuth.githubAuth.clientSecret,
      callbackURL: configAuth.githubAuth.callbackURL
    },
    function(accessToken, refreshToken, profile, done) {
      process.nextTick(function() {
        authCallback('github', profile, {accessToken, refreshToken}, done);
      });
    }
  ));
};
const undefsafe = require('undefsafe');
const passport = require('passport');
const request = require('request');
const User = require('../db/user');
const Strategy = require('passport-github2').Strategy;

const strategy = new Strategy({
  clientID: process.env.GITHUB_CLIENT_ID,
  clientSecret: process.env.GITHUB_SECRET,
  callbackURL: process.env.GITHUB_CALLBACK,
}, (accessToken, refreshToken, profile, done) => {
  const email = undefsafe(profile, 'emails.0.value');
  User
    .findOrCreate({ githubId: profile.id, email }, profile._json)
    .then(user => {
      if (user.email) {
        return done(null, user);
      }

      // otherwise go get their email address and store it
      request({
        url: 'https://api.github.com/user/emails',
        json: true,
const passport = require('passport');
const request = require('request');
const User = require('../db/user');
const Strategy = require('passport-github2').Strategy;

const strategy = new Strategy(
  {
    clientID: process.env.GITHUB_CLIENT_ID,
    clientSecret: process.env.GITHUB_SECRET,
    // callbackURL: process.env.GITHUB_CALLBACK,
  },
  (accessToken, refreshToken, profile, done) => {
    User.findOrCreate({ githubId: profile.id }, profile._json)
      .then(user => {
        if (user.email) {
          return done(null, user);
        }

        // otherwise go get their email address and store it
        request(
          {
            url: 'https://api.github.com/user/emails',
function configureGithubOAuth(app, options) {
	if (options.configParams.get("orion.oauth.github.client")) {
		const GithubStrategy = require('passport-github2').Strategy;
		passport.use(new GithubStrategy({
			clientID: options.configParams.get("orion.oauth.github.client"),
			clientSecret: options.configParams.get("orion.oauth.github.secret"),
			passReqToCallback: true,
			callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback",
			scope: "user:email"
		}, /* @callback */ function(req, accessToken, refreshToken, profile, done) {
			const email = profile.emails[0].value;
			oauth(profile.provider + "/" + profile.id, profile.username, email, req, done);
		}));
		app.get('/login/oauth/github', options.basicMiddleware, passport.authenticate('github'));
		app.get('/mixlogin/manageoauth/oauth/github', options.basicMiddleware, passport.authenticate('github', {callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback/link"}));
		app.get('/auth/github/callback*', options.basicMiddleware, function(req, res) {
			return passport.authenticate('github', {callbackURL: (options.configParams.get("orion.auth.host") || "") + "/auth/github/callback" + (req.params["0"] || "")}, /* @callback */ function(err, user, info){
				createNewUser(req,res,err,user, options);
			})(req,res);
		});

Is your System Free of Underlying Vulnerabilities?
Find Out Now