Link back and front all get #115

Merged
tonitch merged 40 commits from wal/front/listingUsers into master 2024-03-18 20:20:37 +01:00
2 changed files with 14 additions and 0 deletions
Showing only changes of commit 345599888d - Show all commits

View File

@ -40,6 +40,16 @@ public class UserController {
return new ResponseEntity<>(ProtectionService.userWithoutPassword(user), HttpStatus.OK); return new ResponseEntity<>(ProtectionService.userWithoutPassword(user), HttpStatus.OK);
} }
@GetMapping("/user/{id}")
public ResponseEntity<HashMap<String ,Object>> getUserById(@RequestHeader("Authorization") String token, @PathVariable Long id){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
return new UnauthorizedResponse<>(null);
return new ResponseEntity<>(ProtectionService.userWithoutPassword(userService.getUserById(id)), HttpStatus.OK);
}
@PostMapping("/user") @PostMapping("/user")
public ResponseEntity<Map<String ,Object>> postUser(@RequestBody User user,@RequestHeader("Authorization") String token){ public ResponseEntity<Map<String ,Object>> postUser(@RequestBody User user,@RequestHeader("Authorization") String token){

View File

@ -122,4 +122,8 @@ public class UserService {
public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();} public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();}
public Iterable<User> getAllStudents(){return userRepo.findAllStudents();} public Iterable<User> getAllStudents(){return userRepo.findAllStudents();}
public User getUserById(long id) {
return userRepo.findById(id);
}
} }