Skip to content

Commit

Permalink
#95
Browse files Browse the repository at this point in the history
  • Loading branch information
vanessapinto257 committed Apr 25, 2019
1 parent b391229 commit 192ad78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion html_frontend/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,21 @@ public User createUser(@Valid @RequestBody User user) {

@CrossOrigin
@RequestMapping("/login")
public ResponseEntity<User> 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> 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<User> 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> 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
Expand Down

0 comments on commit 192ad78

Please sign in to comment.