title: Login by facebook in angular app with loopback backend
body: <p>I'm making an angular application with strongloop loopback backend.</p>
  
  <p>Also I integrating a third party login by facebook using loopback-passport module.</p>
  
  <p>everything was fine in loopback-example-passport and everything is fine in my app right before the moment of redirecting to my app. User and Access-token created.</p>
  
  <p>the code:</p>
  
  <pre><code>app.get('/auth/login', ensureLoggedIn('/#login'), function(req, res, next) {
      console.log('LOOGED IN!!');
  console.log(req.user);
  
    res.redirect('/#auth/login');
  });
  </code></pre>
  
  <p>works fine. But i can't understand. how to give authenticated state to my angular application.</p>
  
  <p>i tried to make a controller to route '/#auth/login':</p>
  
  <pre><code>.controller('AuthCalbackCtrl', function($scope, $cookies, $location, AppAuth, $http, User, LoopBackAuth) {
  //analogue of User.login responce interceptor
     LoopBackAuth.currentUserId = $cookies['userId'] || null;
     LoopBackAuth.accessTokenId = $cookies['access-token'] || '';
     LoopBackAuth.rememberMe = false;
     LoopBackAuth.save();
     //asking for currentUser
     User.getCurrent(function(user) {
       console.log('ser.getCurrent ', user);
     });
     $location.path('/');
    })
  </code></pre>
  
  <p>This code makes a request GET /api/users/2 but receives 401 error.</p>
  
  <p>If I tweak the file /loopback/lob/models/user.js setting permission:       </p>
  
  <pre><code>  principalType: ACL.ROLE,
    // principalId: Role.OWNER,
    principalId: Role.EVERYONE,
    permission: ACL.ALLOW,
    property: "findById"
  </code></pre>
  
  <p>Then the request GET /api/users/2 receives 200 and everything ok.</p>
  
  <p>I'm a little confused. I can`t understand how to make my angular app authenticate to loopback, although i know access-token and userId</p>
  
  <p>Have anybody any ideas how to do it?</p>