Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ private boolean isGoogleClassroomEnabled() {
return !googleClientId.isEmpty() && !googleClientSecret.isEmpty();
}

@Secured("ROLE_USER")
@PostMapping("/check-authentication")
HashMap<String, Object> checkAuthentication(@RequestParam("username") String username,
@RequestParam("password") String password) {
Expand All @@ -188,12 +189,18 @@ HashMap<String, Object> checkAuthentication(@RequestParam("username") String use
response.put("isUsernameValid", false);
response.put("isPasswordValid", false);
} else {
boolean isPasswordValid = userService.isPasswordCorrect(user, password);
response.put("isUsernameValid", true);
response.put("isPasswordValid", userService.isPasswordCorrect(user, password));
response.put("userId", user.getId());
response.put("username", user.getUserDetails().getUsername());
response.put("firstName", user.getUserDetails().getFirstname());
response.put("lastName", user.getUserDetails().getLastname());
response.put("isPasswordValid", isPasswordValid);
// Only reveal the account id and real name once the correct password has been
// provided, so this endpoint cannot be used to harvest user ids and real names
// by probing usernames.
if (isPasswordValid) {
response.put("userId", user.getId());
response.put("username", user.getUserDetails().getUsername());
response.put("firstName", user.getUserDetails().getFirstname());
response.put("lastName", user.getUserDetails().getLastname());
}
}
return response;
}
Expand Down