moved portective method to Static ProtectiveService
This commit is contained in:
@ -5,6 +5,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Services.ProtectionService;
|
||||
import ovh.herisson.Clyde.Services.UserService;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
@ -35,7 +36,7 @@ public class UserController {
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if (user == null) return new UnauthorizedResponse<>(null);
|
||||
|
||||
return new ResponseEntity<>(authServ.userWithoutPassword(user), HttpStatus.OK);
|
||||
return new ResponseEntity<>(ProtectionService.userWithoutPassword(user), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/user")
|
||||
@ -44,7 +45,7 @@ public class UserController {
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.InscriptionService,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
return new ResponseEntity<>(authServ.userWithoutPassword(userService.save(user)),HttpStatus.CREATED);
|
||||
return new ResponseEntity<>(ProtectionService.userWithoutPassword(userService.save(user)),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@GetMapping("/users")
|
||||
@ -57,7 +58,7 @@ public class UserController {
|
||||
ArrayList<HashMap<String, Object>> withoutPassword = new ArrayList<>();
|
||||
|
||||
for (User u :users){
|
||||
withoutPassword.add(authServ.userWithoutPassword(u));
|
||||
withoutPassword.add(ProtectionService.userWithoutPassword(u));
|
||||
}
|
||||
return new ResponseEntity<>(withoutPassword, HttpStatus.OK);
|
||||
}
|
||||
@ -95,7 +96,7 @@ public class UserController {
|
||||
ArrayList<HashMap<String, Object>> withoutPassword = new ArrayList<>();
|
||||
|
||||
for (User t: teachers){
|
||||
withoutPassword.add(authServ.userWithoutPassword(t));
|
||||
withoutPassword.add(ProtectionService.userWithoutPassword(t));
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(withoutPassword, HttpStatus.OK);
|
||||
|
Reference in New Issue
Block a user