title: Loopback angular sdk unable to login
body: <p>I'm trying to use loopback angular SDK to login but instead I'm getting back a 401 unauthorized response.</p>
  
  <pre><code>User.login({ rememberMe: true }, {email: $scope.user.email, password: $scope.user.password})
        .$promise
        .then(function() {
            var next = $location.nextAfterLogin || '/';
            $location.nextAfterLogin = null;
            $location.path(next);
        })
        .catch(function(x) {
            $scope.authError = 'Wrong Credentials';
        });
    };
  </code></pre>
  
  <p>Also i can see the user with the given credentials in the datasource that I've defined for the User model. </p>
  
  <p>So basically, I have a boot script that creates a default user</p>
  
  <pre><code> User.create([{
      username: 'admin',
      email: 'xxxx@gmail.com',
      password: 'admin'
  }], on_usersCreated);
  </code></pre>
  
  <p>And I also have created a custom User model that extends the built-in User model.</p>
  
  <p>Why am I getting a 401 unauthorized response when trying to login? I have even tried to login via the explorer, but with no success.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>I debugged the build-in User model and the login method; and it seems that it cannot find the user with the given email. I can see it though in the mongodb database.</p>