diff --git a/html_frontend/login.html b/html_frontend/login.html index caa89f3..5cca06e 100644 --- a/html_frontend/login.html +++ b/html_frontend/login.html @@ -233,7 +233,7 @@ function login() { if(validateLoginForm()){ - var api_url = 'http://149.165.171.50:30008/api/login?username='+document.getElementById("username_login").value+'&password='+document.getElementById("password_login").value; + var api_url = 'http://149.165.171.50:30008/api/login?username='+document.getElementById("username_login").value+'&password='+document.getElementById("password_login").value+"&social=&firstname=&lastname"; $.ajax({ type:'get', dataType:'json', diff --git a/java_api/park-my-car/src/main/java/com/project/parkmycar/controller/UserController.java b/java_api/park-my-car/src/main/java/com/project/parkmycar/controller/UserController.java index 519b0e9..e622882 100644 --- a/java_api/park-my-car/src/main/java/com/project/parkmycar/controller/UserController.java +++ b/java_api/park-my-car/src/main/java/com/project/parkmycar/controller/UserController.java @@ -72,19 +72,21 @@ public User createUser(@Valid @RequestBody User user) { @CrossOrigin @RequestMapping("/login") - public ResponseEntity login(@RequestParam("username") String username, @RequestParam("password") String password, HttpServletRequest request, Model m, HttpSession session){ - BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); -// String hashedPassword = passwordEncoder.encode(password); - Optional user = userRepository.findAllByUserName(username); - System.out.println("Hellllllllooooooo"); - System.out.println(session.getAttribute("user")); - if(user.get().getUserName().equals(username) && passwordEncoder.matches(password, user.get().getPassword())) { - return new ResponseEntity<>(user.get(),HttpStatus.OK); - } - else { - return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + public ResponseEntity login(@RequestParam("username") String username, @RequestParam("password") String password, @RequestParam("social") String social, @RequestParam("firstname") String firstname, @RequestParam("lastname") String lastname, HttpServletRequest request, Model m, HttpSession session){ + if(social == "") { + BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); +// String hashedPassword = passwordEncoder.encode(password); + Optional user = userRepository.findAllByUserName(username); + System.out.println("Hellllllllooooooo"); + System.out.println(session.getAttribute("user")); + if(user.get().getUserName().equals(username) && passwordEncoder.matches(password, user.get().getPassword())) { + return new ResponseEntity<>(user.get(),HttpStatus.OK); + } + else { + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } } - + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } @CrossOrigin