post User by secretary

This commit is contained in:
2024-04-21 23:14:56 +02:00
parent 608b6e4893
commit 1a266cdfbd
10 changed files with 208 additions and 90 deletions

View File

@ -74,7 +74,8 @@ public class ApplicationsController {
authorizedApps.add(Applications.Requests);
authorizedApps.add(Applications.StudentsList);}
if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){
if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){
authorizedApps.add(Applications.CreateUser);
authorizedApps.add(Applications.UsersList);}
if (researchesServ.getResearcherByUser(user) != null)

View File

@ -86,19 +86,20 @@ public class UserController {
* @return a string clarifying the issue (if there is any)
*/
@PatchMapping("/user/{id}")
public ResponseEntity<String> patchUser(@RequestHeader("Authorization") String token,
public ResponseEntity<Map<String,Object>> patchUser(@RequestHeader("Authorization") String token,
@RequestBody Map<String,Object> updates,
@PathVariable Long id) {
if (token == null) return new UnauthorizedResponse<>(null);
User poster = authServ.getUserFromToken(token);
if (poster == null) {return new UnauthorizedResponse<>("bad token");}
if (poster == null) {return new UnauthorizedResponse<>(null);}
if (!userService.modifyData(id, updates, poster))
User modified = userService.modifyData(id,updates,poster);
if (modified ==null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(null, HttpStatus.OK);
return new ResponseEntity<>(ProtectionService.userWithoutPassword(modified), HttpStatus.OK);
}
@GetMapping("/teachers")