title: Combining koa-passport with koa-router (getting user data)
body: <p>I have created a login which is able to login a user and store the user if they are new in the database.</p>
  
  <p>The user is then redirected to <code>/</code> and then is checked if they are authenticated or not, see below (app.js):</p>
  
  <pre><code>.get('/', function* () {
      if (this.isAuthenticated()) {
          yield this.render('homeSecure', {}); // &lt;-- need user data here
      } else {
          yield this.render('homePublic', {});
      }
  </code></pre>
  
  <p>As I commented in the code, I would like to send the user object of which is logged in. I have no idea how to get a hold of the id of the person logged in as the documentation for koa in general is not as complete as that of express.</p>
  
  <p>I am using <code>koa-generic-session-mongo</code> to handle my sessions. Here is my GoogleStrategy (auth.js):</p>
  
  <pre><code>var user = null;
  // ...
  var GoogleStrategy = require('passport-google').Strategy;
  passport.use(new GoogleStrategy({
          returnURL: 'http://localhost:' + (process.env.PORT || 3000) + '/auth/google/callback',
          realm: 'http://localhost:' + (process.env.PORT || 3000)
      },
      function (identifier, profile, done) {
          var emails = new Array();
          for (var i = 0; i &lt; profile.emails.length; i++) {
              emails.push(profile.emails[i].value);
          }
          co(function* () {
              yield users.findOne({
                  emails: emails
              });
          });
          if (user === null) { // first time signin, create account
              co(function* () {
                  user = {
                      id: 1,
                      name: profile.displayName,
                      emails: emails
                  };
                  yield users.insert(user);
              });
          }
          console.log(user);
          done(null, user);
      }));
  </code></pre>