Working with Spring LDAP and AngularJS

222 views Asked by At

I was tasked to implement Spring LDAP in the back-end of an application and I'm having some trouble doing so, especially with my back-end and front-end communication On my front-end I created a function on my controller thar calls a service responsible for sending the user inputs:

Controller:

scope.login = function() {
   if(!$scope.validateLogin()){
      return false;
   }
   authenticationService.Login($scope.user, $scope.password, function(response) {
      if (response.authenticated) {
         console.log("success - "+response);
      } else {
         console.log("error - "+response);
      }
  });
}

Service:

this.Login = function (username, password, callback) {
   var headers = {
      authorization : "Basic " + btoa(username + ":" + password)
   };
   var jsonData = JSON.stringify(headers);

   $http.get('http://localhost:8080/user', {headers : headers, data: jsonData})
   .success(function (response) {
       callback(response);
   })
   .error(function (response){
       callback(response);
   });
};

But then, when it reaches my back-end, "Principal user" comes null

@RequestMapping("/user")
public Principal user(Principal user) {
    return user;
}

Does anybody know what I am doing wrong ?

0

There are 0 answers