Compare commits
No commits in common. "76f5a39a8f91c47448182f447374d96d4e1ff6b7" and "ea46dd664cd3ea193dfd754c5e6a6199fa84b79e" have entirely different histories.
76f5a39a8f
...
ea46dd664c
@ -54,6 +54,8 @@ public class ApplicationsController {
|
||||
// if authed
|
||||
authorizedApps.add(Applications.Profile);
|
||||
|
||||
Role posterRole = user.getRole();
|
||||
|
||||
if (!authServ.isNotIn(new Role[]{Role.Teacher,Role.Student,Role.Admin},token)) {
|
||||
authorizedApps.add(Applications.Msg);
|
||||
authorizedApps.add(Applications.Forum);
|
||||
|
@ -9,8 +9,6 @@ import ovh.herisson.Clyde.Services.ProtectionService;
|
||||
import ovh.herisson.Clyde.Services.UserService;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -55,15 +53,7 @@ public class UserController {
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
Role posterRole = authServ.getUserFromToken(token).getRole();
|
||||
|
||||
Iterable<User> users = new ArrayList<>();
|
||||
|
||||
if (posterRole == Role.Admin)
|
||||
users = userService.getAll();
|
||||
|
||||
else if (posterRole == Role.Secretary)
|
||||
users = userService.getAllExceptAdmins();
|
||||
Iterable<User> users = userService.getAll();
|
||||
|
||||
return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(users), HttpStatus.OK);
|
||||
}
|
||||
|
@ -10,14 +10,9 @@ public interface UserRepository extends CrudRepository<User, Long> {
|
||||
|
||||
User findByEmail(String email);
|
||||
|
||||
|
||||
|
||||
@Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Teacher")
|
||||
Iterable<User> findAllTeachers();
|
||||
|
||||
@Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Student")
|
||||
Iterable<User> findAllStudents();
|
||||
|
||||
@Query("select u from User u where u.role <> ovh.herisson.Clyde.Tables.Role.Admin")
|
||||
Iterable<User> findAllExceptAdmins();
|
||||
}
|
@ -114,10 +114,6 @@ public class UserService {
|
||||
return userRepo.findAll();
|
||||
}
|
||||
|
||||
public Iterable<User> getAllExceptAdmins(){
|
||||
return userRepo.findAllExceptAdmins();
|
||||
}
|
||||
|
||||
|
||||
public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user