Compare commits

..

2 Commits

Author SHA1 Message Date
4f002a29e1 Merge pull request 'added delete self' (#145) from Max/Backend/UserDelete into master
Some checks failed
deploy to production / deploy-frontend (push) Waiting to run
deploy to production / deploy-backend (push) Waiting to run
Build and test FrontEnd / Build-frontend (push) Waiting to run
Build and test backend / Build-backend (push) Has been cancelled
Reviewed-on: #145
Reviewed-by: Wal <karpinskiwal@gmail.com>
Reviewed-by: LeoMoulin <leomoulin125@gmail.com>
Reviewed-by: Debucquoy Anthony <d.tonitch@gmail.com>
2024-03-18 20:19:41 +01:00
a276c24f8f added delete self
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m2s
Build and test backend / Test-backend (pull_request) Successful in 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 25s
2024-03-18 17:30:04 +01:00

View File

@ -124,7 +124,7 @@ public class UserController {
@DeleteMapping("/user/{id}") @DeleteMapping("/user/{id}")
public ResponseEntity<String> deleteStudent(@RequestHeader("Authorization") String token, @PathVariable Long id){ public ResponseEntity<String> deleteStudent(@RequestHeader("Authorization") String token, @PathVariable Long id){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token)) if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token) || id.equals(authServ.getUserFromToken(token).getRegNo()))
return new UnauthorizedResponse<>(null); return new UnauthorizedResponse<>(null);
User toDelete = userService.getUserById(id); User toDelete = userService.getUserById(id);