Pasaporte: redirección diferente para inicio de sesión y registro de cuenta.

Estoy usando el módulo de pasaporte (autenticación Github) en mi aplicación y quiero redirigir según la acción ... Verifico si es solo un inicio de sesión normal o si el usuario inicia sesión por primera vez.

<code>passport.use(new GitHubStrategy({
    clientID: conf.github.app_id,
    clientSecret: conf.github.app_secret,
    callbackURL: conf.github.callback_url
  },
  function(accessToken, refreshToken, profile, done) {
    // asynchronous verification, for effect...
    process.nextTick(function () {

      // 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.

      Models_User.findOrCreateUser(profile, function(msg){
        console.log("auth type:" + msg);
      });

      return done(null, profile);

    });
  }
));
</code>

en mi función findOrCreateUser, compruebo si es un usuario nuevo y hago toda la acción db ... para probar, permito que la función devuelva una variable msg que es solo una cadena que dice "login" o "new_registration".

así que mi pregunta es cómo "transportar" esa variable que obtengo de findOrCreateUser para que pueda redirigir en consecuencia ("/ welcome" o "/ back_again") después de que se haya completado la autenticación del pasaporte.

el otro código de pasaporte en mi aplicación:

<code>// GET /auth/github
//   Use passport.authenticate() as route middleware to authenticate the
//   request.  The first step in GitHub authentication will involve redirecting
//   the user to github.com.  After authorization, GitHubwill redirect the user
//   back to this application at /auth/github/callback
app.get('/auth/github',
  passport.authenticate('github'),
  //passport.authenticate('github', { scope: ['user', 'public_repo', 'gist'] }),
  function(req, res){
    // The request will be redirected to GitHub for authentication, so this
    // function will not be called.
  });

// GET /auth/github/callback
//   Use passport.authenticate() as route middleware to authenticate the
//   request.  If authentication fails, the user will be redirected back to the
//   login page.  Otherwise, the primary route function function will be called,
//   which, in this example, will redirect the user to the home page.
app.get('/auth/github/callback', 
  passport.authenticate('github', { successRedirect: '/', failureRedirect: '/login' }),
  function(req, res) {
    res.redirect('/');
  });
</code>

Respuestas a la pregunta(1)

Su respuesta a la pregunta