added delete self
This commit is contained in:
parent
fd357ba938
commit
a276c24f8f
@ -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