Merge pull request 'added delete self' (#145) from Max/Backend/UserDelete into master
Reviewed-on: PGL/Clyde#145 Reviewed-by: Wal <karpinskiwal@gmail.com> Reviewed-by: LeoMoulin <leomoulin125@gmail.com> Reviewed-by: Debucquoy Anthony <d.tonitch@gmail.com>
This commit is contained in:
commit
4f002a29e1
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user