title: How to login with @RestController and send the object to angularjs
body: <p>I have some trouble figuring out how to create a login form in angularjs using springboot.</p>
  
  <p>I can register a user and send the data to the database but the problems begin when i want to login.</p>
  
  <p>in angularjs i have a function like this</p>
  
  <pre><code>  function Login(username, password, callback) {
  
  
          $http.post('/api/authenticate', { username: username, password: password })
             .success(function (response) {
                callback(response);
             });
  
      }
  </code></pre>
  
  <p>What i managed to do but probably is't right:</p>
  
  <pre><code>@RequestMapping(value = "/authenticate/{id}",method = RequestMethod.GET)
  public  User getUser(@PathVariable Integer id) {
  
      return repo.findOne(id);
  }
  </code></pre>
  
  <p>This gives me following json </p>
  
  <pre><code>{"id":2,"username":"jdoe","password":"$2a$10$5hgIyQr.K9wb8cXEyWGbROAU.rkYzd19vP7ajHpwp1KUYdShfcPn.","lastname":"doe","firstname":"john","customfield":"Hello there"}
  </code></pre>
  
  <p>But now i have following problems and questions :</p>
  
  <p>How can i check if the username and password is equal to the username and password of json by going to api/authenticate ? (without {id})</p>
  
  <p>can i hide this json from the users ?</p>
  
  <p>Is this safe ?</p>
  
  <p>how will angular now all the users propertys ? (i suggest i can retrieve this from the json)</p>
  
  <p>any pro tips on how to solve this?</p>