title: Meteor: Login over DDP and retrieve current user object in seperate Meteor app
body: <p>First a little background:</p>
  
  <p>I am working on an seperate mobile application that is connected with the main app. The connection is succesfully initiated and I can retrieve all collections, through subscriptions:</p>
  
  <pre><code>Remote = DDP.connect('http://localhost:3000/');
  
  Meteor.users = new Meteor.Collection('users', {
      connection: Remote
  });
  
  Remote.subscribe('users', true);
  </code></pre>
  
  <p>Now I want to make sure users can log in through the interface of the second app. After installing the accounts-password and the <a href="https://github.com/ongoworks/meteor-ddp-login" rel="nofollow">meteor-ddp-login</a> package, I should be able to authenticate with the main app by using the next piece of code in the client side.</p>
  
  <pre><code>var Remote = DDP.connect('http://localhost:3000/');
  
  DDP.loginWithPassword(Remote, {
      username: username
  }, password, function(error) {
      if (!error) {
          console.log(username + " is logged in!");
      } else {
          console.log(error);
      }
  });
  </code></pre>
  
  <p>Well, so far so good. No errors appear and the console logs a success message. Now the question comes:</p>
  
  <p><strong>How can I retrieve the user object of the user who just logged in.</strong></p>
  
  <p>I've set up several publish functions in the main app, but the user data does not become available to the client in the second app (other collections work fine, but Meteor.user() is undefined).</p>
  
  <p>And also: <strong>How can I authenticate users who login with Facebook/Google/Twitter</strong></p>