Skip to content
Snippets Groups Projects
Commit a118af7a authored by Birk Øvstetun Narvhus's avatar Birk Øvstetun Narvhus
Browse files

fixed authentication on get user endpoint

parent e6651837
No related branches found
No related tags found
No related merge requests found
......@@ -91,7 +91,12 @@ public class UserController {
* @return The user with the given username.
*/
@GetMapping("/get/{username}")
public ResponseEntity<User> getUser(@PathVariable String username) {
public ResponseEntity<User> getUser(@PathVariable String username, Authentication authentication) {
if (!username.equals(authentication.getName()) &&
!authentication.getAuthorities().contains(new SimpleGrantedAuthority(Authority.ADMIN.name())))
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
return userService.getUserFromUsername(username)
.map(user -> {
user.setPassword(null);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment