1
0
forked from PGL/Clyde

added /students endpoint

This commit is contained in:
2024-03-16 23:05:26 +01:00
parent 069466ef5f
commit 4379794dba
3 changed files with 23 additions and 0 deletions

View File

@ -90,6 +90,24 @@ public class UserController {
}
@GetMapping("/students")
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllStudent(@RequestHeader("Authorization") String token){
if (authServ.getUserFromToken(token) == null)
return new UnauthorizedResponse<>(null);
Iterable<User> teachers = userService.getAllStudents();
ArrayList<HashMap<String, Object>> withoutPassword = new ArrayList<>();
for (User t: teachers){
withoutPassword.add(userWithoutPassword(t));
}
return new ResponseEntity<>(withoutPassword, HttpStatus.OK);
}
/** return user's data except password
* @param user the user to return