lib/oauth.js
function initSession(req, res, next) {
    var provider = getProvider(req.path);
    return user.createSession(req.user._id, provider, req)
      .then(function(mySession) {
        return BPromise.resolve({
          error: null,
          session: mySession,
          link: null
        });
      })
      .then(function (results) {
        var template;
        if(config.getItem('testMode.oauthTest')) {
          template = fs.readFileSync(path.join(__dirname, '../templates/oauth/auth-callback-test.ejs'), 'utf8');
        } else {
          template = fs.readFileSync(path.join(__dirname, '../templates/oauth/auth-callback.ejs'), 'utf8');
        }
        var html = ejs.render(template, results);
        res.status(200).send(html);
      }, function (err) {
        return next(err);
      });
  }
function initSession(req, res, next) {
    var provider = getProvider(req.path);
    return user.createSession(req.user._id, provider, req)
      .then(function(mySession) {
        return BPromise.resolve({
          error: null,
          session: mySession,
          link: null
        });
      })
      .then(function (results) {
        var template;
        if(config.getItem('testMode.oauthTest')) {
          template = fs.readFileSync(path.join(__dirname, '../templates/oauth/auth-callback-test.ejs'), 'utf8');
        } else {
          template = fs.readFileSync(path.join(__dirname, '../templates/oauth/auth-callback.ejs'), 'utf8');
        }
        var html = ejs.render(template, results);
        res.status(200).send(html);
      }, function (err) {
        return next(err);
      });
  }
Function to initialize a session following authentication from a socialAuth provider